assetfs

package
v0.0.0-...-e61ee7f Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Layer

type Layer struct {
	// contains filtered or unexported fields
}

Layer represents a layer in a layered asset file-system. It has a name and works like http.FileSystem

func Bindata

func Bindata(name string, fs http.FileSystem) *Layer

Bindata returns a new Layer with the given name, it serves files from the given bindata asset.

func Local

func Local(name, base string, sub ...string) *Layer

Local returns a new Layer with the given name, it serves files from the given local path.

func (*Layer) Name

func (l *Layer) Name() string

func (*Layer) Open

func (l *Layer) Open(name string) (http.File, error)

Open opens the named file. The caller is responsible for closing the file.

type LayeredFS

type LayeredFS struct {
	// contains filtered or unexported fields
}

LayeredFS is a layered asset file-system. It works like http.FileSystem, but it can have multiple layers. The first layer is the top layer, and it will be used first. If the file is not found in the top layer, it will be searched in the next layer.

func Layered

func Layered(layers ...*Layer) *LayeredFS

Layered returns a new LayeredFS with the given layers. The first layer is the top layer.

func (*LayeredFS) GetFileLayerName

func (l *LayeredFS) GetFileLayerName(elems ...string) string

GetFileLayerName returns the name of the first-seen layer that contains the given file.

func (*LayeredFS) ListAllFiles

func (l *LayeredFS) ListAllFiles(name string, fileMode ...bool) ([]string, error)

ListAllFiles returns files/directories in the given directory, including subdirectories, recursively. The fileMode controls the returned files: * omitted: all files and directories will be returned. * true: only files will be returned. * false: only directories will be returned. The returned files are sorted by name.

func (*LayeredFS) ListFiles

func (l *LayeredFS) ListFiles(name string, fileMode ...bool) ([]string, error)

ListFiles lists files/directories in the given directory. The fileMode controls the returned files. * omitted: all files and directories will be returned. * true: only files will be returned. * false: only directories will be returned. The returned files are sorted by name.

func (*LayeredFS) Open

func (l *LayeredFS) Open(name string) (http.File, error)

Open opens the named file. The caller is responsible for closing the file.

func (*LayeredFS) ReadFile

func (l *LayeredFS) ReadFile(elems ...string) ([]byte, error)

ReadFile reads the named file.

func (*LayeredFS) ReadLayeredFile

func (l *LayeredFS) ReadLayeredFile(elems ...string) ([]byte, string, error)

ReadLayeredFile reads the named file, and returns the layer name.

func (*LayeredFS) WatchLocalChanges

func (l *LayeredFS) WatchLocalChanges(ctx context.Context, callback func())

WatchLocalChanges watches local changes in the file-system. It's used to help to reload assets when the local file-system changes.

Jump to

Keyboard shortcuts

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