tree

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2019 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader func(context.Context) ([]byte, error)

Loader is a function that loads file content. If the context id done this function should return an error.

type Opener

type Opener interface {
	// Open returns a file/dir.
	Open() http.File
	// Stat returns information about the file/dir.
	Stat() (os.FileInfo, error)
	// Readdir retruns list of file info contained in a directory.
	// Preforming Readdir on a file returns nil, nil.
	Readdir(count int) ([]os.FileInfo, error)
}

Opener is an interface for a directory or a file provider.

type Tree

type Tree map[string]Opener

Tree maps a file path to a file provider. It implements http.FileSystem.

func (Tree) AddDir

func (t Tree) AddDir(path string) error

AddDir adds a directory to a tree. It also adds recursively all the parent directories.

func (Tree) AddFile

func (t Tree) AddFile(path string, size int, load Loader) error

AddFile adds a file to a tree. It also adds recursively all the parent directories.

func (Tree) AddFileContent added in v0.1.0

func (t Tree) AddFileContent(path string, content []byte) error

AddFileContent adds a file that its content is already available.

func (Tree) Open added in v0.0.2

func (t Tree) Open(name string) (http.File, error)

Open is the implementation of http.FileSystem.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL