Documentation ¶
Overview ¶
Package vfs contains abstractions for working with virtual filesystems. These are used to abstract access to files that may come from several different places, and to limit the ability to read files outside of those places expressly allowed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Empty = Internal("<EMPTY>", EmptyFileSystem{})
Empty is an empty filesystem. It is marked as internal, since it is an implementation detail used to prevent relative resolution of (module) paths.
var Nowhere = Location{}
Nowhere is a zero value to use when e.g,. module resolution fails.
Functions ¶
This section is empty.
Types ¶
type EmptyFileSystem ¶
type EmptyFileSystem struct{}
EmptyFileSystem is an http.FileSystem with no files.
type FileSystem ¶
type FileSystem interface { http.FileSystem // IsInternal returns true if a filesystem should be considered // internal to the system, and therefore not recorded IsInternal() bool // QualifyPath gives a path within the filesystem a identifying , // used both for reporting its location unambiguously (though not // necessarily using a valid path), and e.g., to avoid loading // modules more than once. QualifyPath(path string) string }
FileSystem is an interface for filesystems used to source modules, files, and resources.
func Chroot ¶
func Chroot(vfs FileSystem, newRoot string) FileSystem
Chroot makes a given directory appear to be the root of the filesystem.
type InternalFileSystem ¶
type InternalFileSystem struct { http.FileSystem // contains filtered or unexported fields }
InternalFileSystem is a way to wrap a regular http.FileSystem so that it appears to be internal to the workings of the runtime, e.g., so reads don't get recorded.
func Internal ¶
func Internal(prefix string, fs http.FileSystem) InternalFileSystem
Internal is a convenience for creating an internal (system) filesystem
func (InternalFileSystem) IsInternal ¶
func (f InternalFileSystem) IsInternal() bool
IsInternal implements the method of FileSystem, in the positive by definition.
func (InternalFileSystem) QualifyPath ¶
QualifyPath takes a path assumed to be within the filesystem, and qualifies it using the prefix assigned.
type Location ¶
type Location struct { Vfs FileSystem Path string }
Location is a path within a specific filesystem.
func (Location) CanonicalPath ¶
CanonicalPath gives an identifying (though not necessarily valid) path for the location, by including the filesystem's identity via IdentifyingPath.
type UserFileSystem ¶
type UserFileSystem struct { http.FileSystem // contains filtered or unexported fields }
UserFileSystem is a way to wrap a "regular" filesystem (e.g., as constructed by `http.Dir`) so it is marked as a non-system filesystem.
func User ¶
func User(prefix string, fs http.FileSystem) UserFileSystem
User is a convenience for creating a user (non-system) filesystem
func (UserFileSystem) IsInternal ¶
func (u UserFileSystem) IsInternal() bool
IsInternal implements the method of FileSystem, in the negative by definition.
func (UserFileSystem) QualifyPath ¶
QualifyPath takes a path assumed to be within the filesystem, and qualifies it using the prefix assigned.