tree

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

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