Documentation
¶
Overview ¶
Package rwvfs augments vfs to support write operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrReadOnly = errors.New("read-only VFS")
ErrReadOnly occurs when a write method (Create, Mkdir, Remove) is called on a read-only VFS (i.e., one created by ReadOnly).
Functions ¶
func Glob ¶
func Glob(wfs WalkableFileSystem, prefix, pattern string) (matches []string, err error)
Glob returns the names of all files under prefix matching pattern or nil if there is no matching file. The syntax of patterns is the same as in path/filepath.Match.
func MkdirAll ¶
func MkdirAll(fs FileSystem, path string) error
MkdirAll creates a directory named path, along with any necessary parents. If path is already a directory, MkdirAll does nothing and returns nil.
Types ¶
type FileSystem ¶
type FileSystem interface { vfs.FileSystem // Create creates the named file, truncating it if it already exists. Create(path string) (io.WriteCloser, error) // Mkdir creates a new directory. If name is already a directory, Mkdir // returns an error (that can be detected using os.IsExist). Mkdir(name string) error // Remove removes the named file or directory. Remove(name string) error }
func Map ¶
func Map(m map[string]string) FileSystem
Map returns a new FileSystem from the provided map. Map keys should be forward slash-separated pathnames and not contain a leading slash.
func OS ¶
func OS(root string) FileSystem
OS returns an implementation of FileSystem reading from the tree rooted at root.
func ReadOnly ¶
func ReadOnly(fs vfs.FileSystem) FileSystem
ReadOnly returns a FileSystem whose write methods (Create, Mkdir, Remove) return errors. All other methods pass through to the read-only VFS.
func Sub ¶
func Sub(fs FileSystem, prefix string) FileSystem
Sub returns an implementation of FileSystem mounted at prefix on the underlying fs. If fs doesn't have an existing directory at prefix, you can can call Mkdir("/") on the new filesystem to create it.
type WalkableFileSystem ¶
type WalkableFileSystem interface { FileSystem Join(elem ...string) string }
func Walkable ¶
func Walkable(fs FileSystem) WalkableFileSystem
Walkable creates a walkable VFS by wrapping fs.