Documentation

Index

Constants

This section is empty.

Variables

var ErrLStat = errors.NewError("error calling Lstat()")

var ErrNoVirtualFileSystems = errors.NewError("no virtual file systems configured or found")

var ErrOpen = errors.NewError("error opening file")

var ErrReadingDirectory = errors.NewError("error reading directory")

var ErrStat = errors.NewError("error calling Stat()")

Functions

func Glob

func Glob(pattern string, fs FileSystem) (matches []string, err error)

Glob match the specified pattern against the contents of fs.

TODO: Consider implementing recursive globbing via "**" operators, e.g.: `**/*.txt` would match all .txt files in the current directory and below.

func HTTPDir

func HTTPDir(fs FileSystem) *httpdir

Types

type FileSystem

type FileSystem interface {
	Open(name string) (ReadSeekCloser, error)
	Lstat(name string) (os.FileInfo, error)
	Stat(name string) (os.FileInfo, error)
	ReadDir(name string) ([]os.FileInfo, error)
	Glob(pattern string) (matches []string, err error)
}

type Notifier

type Notifier interface {
	Watch(func()) error
	CloseWatches() error
}

type NullableFileSystem

type NullableFileSystem interface {
	FileSystem
	IsEmpty() bool
}

NullableFileSystem should be implemented for those types that could potentially be returned in a null state wherein such circumstances may be disguised by the interface. Usually implementing this with

func (t *Type) IsEmpty() bool {
    return t == nil
}

is considered sufficient.

Because interface types cannot be compared with nil without knowing the underlying type, this is the best option to protect against potential misuse.

type PersistableFileSystem

type PersistableFileSystem interface {
	Path() string
}

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Reader
	io.Seeker
	io.Closer
}

func NopCloser

func NopCloser(r io.ReadSeeker) ReadSeekCloser

type VFSCollection

type VFSCollection struct {
	FileSystems []FileSystem
	// contains filtered or unexported fields
}

func NewVFSCollection

func NewVFSCollection() *VFSCollection

func (*VFSCollection) AddVFS

func (v *VFSCollection) AddVFS(fs FileSystem) *VFSCollection

func (*VFSCollection) Base

func (v *VFSCollection) Base(dir string)

Base forces all VFS requests to this VFSCollection to behave as if they were relative to this directory. For example, setting this to "migrations" and then requsting a file via Open() (e.g. Open("00001-init.sql")) would open the file "migrations/00001-iniit.sql".

func (*VFSCollection) CloseWatches

func (v *VFSCollection) CloseWatches() (err error)

CloseWatches recursively closes any fsnotifier watches that have been previously opened. Useful for cleaning up open file descriptors prior to execve.

func (*VFSCollection) ConsumeVFS

func (v *VFSCollection) ConsumeVFS(fs FileSystem, err error) error

func (*VFSCollection) Glob

func (v *VFSCollection) Glob(pattern string) (files []string, err error)

func (*VFSCollection) Lstat

func (v *VFSCollection) Lstat(path string) (os.FileInfo, error)

func (*VFSCollection) Open

func (v *VFSCollection) Open(name string) (ReadSeekCloser, error)

func (*VFSCollection) ReadDir

func (v *VFSCollection) ReadDir(path string) ([]os.FileInfo, error)

func (*VFSCollection) Stat

func (v *VFSCollection) Stat(path string) (os.FileInfo, error)

func (*VFSCollection) Watch

func (v *VFSCollection) Watch(callback func()) (err error)

Watch satisifies the Notifier interface. This will only be applied if the configured backend support fsnotify.

type VFSFS

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

func NewVFSFS

func NewVFSFS(basepath string, options ...VFSFSOptions) *VFSFS

func (*VFSFS) AddWatcher

func (v *VFSFS) AddWatcher(callback func()) (err error)

func (*VFSFS) CloseWatches

func (v *VFSFS) CloseWatches() error

func (*VFSFS) Glob

func (v *VFSFS) Glob(pattern string) ([]string, error)

func (*VFSFS) Lstat

func (v *VFSFS) Lstat(name string) (os.FileInfo, error)

func (*VFSFS) Open

func (v *VFSFS) Open(name string) (ReadSeekCloser, error)

func (*VFSFS) ReadDir

func (v *VFSFS) ReadDir(name string) ([]os.FileInfo, error)

func (*VFSFS) Stat

func (v *VFSFS) Stat(name string) (os.FileInfo, error)

func (*VFSFS) Watch

func (v *VFSFS) Watch(callback func()) error

type VFSFSOptions

type VFSFSOptions struct {
	RelativeBase bool
	RelativeTo   string
}

type VFSZip

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

func NewVFSZip

func NewVFSZip(path string, basedir ...string) (*VFSZip, error)

func (*VFSZip) Glob

func (v *VFSZip) Glob(pattern string) ([]string, error)

func (*VFSZip) Lstat

func (v *VFSZip) Lstat(name string) (os.FileInfo, error)

func (*VFSZip) Open

func (v *VFSZip) Open(name string) (ReadSeekCloser, error)

func (*VFSZip) ReadDir

func (v *VFSZip) ReadDir(name string) ([]os.FileInfo, error)

func (*VFSZip) Stat

func (v *VFSZip) Stat(name string) (os.FileInfo, error)