Documentation
¶
Overview ¶
Package fs defines basic interfaces to a file system. A file system can be provided by the host operating system but also by other packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadFile ¶
ReadFile reads the named file from the file system fs and returns its contents. A successful call returns a nil error, not io.EOF. (Because ReadFile reads the whole file, the expected EOF from the final Read is not treated as an error to be reported.)
func ValidPath ¶
ValidPath reports whether the given path name is valid for use in a call to Open. Path names passed to open are unrooted, slash-separated sequences of path elements, like “x/y/z”. Path names must not contain a “.” or “..” or empty element, except for the special case that the root directory is named “.”.
Paths are slash-separated on all systems, even Windows. Backslashes must not appear in path names.
Types ¶
type FS ¶
func DirFS ¶
DirFS returns a file system (an fs.FS) for the tree of files rooted at the directory dir.
Note that DirFS("/prefix") only guarantees that the Open calls it makes to the operating system will begin with "/prefix": DirFS("/prefix").Open("file") is the same as os.Open("/prefix/file"). So if /prefix/file is a symbolic link pointing outside the /prefix tree, then using DirFS does not stop the access any more than using os.Open does. DirFS is therefore not a general substitute for a chroot-style security mechanism when the directory tree contains arbitrary content.
type ReadFileFS ¶
type ReadFileFS = fs.ReadFileFS