Documentation ¶
Index ¶
- type File
- type VFS
- func (vfs *VFS) Copy(src io.Reader, dst string) (err error)
- func (vfs *VFS) Create(name string) (File, error)
- func (vfs *VFS) Exists(path string) (bool, error)
- func (vfs *VFS) MkdirAll(path string, perm os.FileMode) error
- func (vfs *VFS) Move(src, dst string) error
- func (vfs *VFS) Open(name string) (File, error)
- func (vfs *VFS) RemoveAll(path string) error
- func (vfs *VFS) Walk(root string, walkFn filepath.WalkFunc) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File interface { io.Closer io.Seeker io.Reader io.ReaderAt io.Writer io.WriterAt // Readdir reads the contents of the directory associated with file and // returns a slice of up to n FileInfo values, as would be returned by // os.File.Readdir Readdir(count int) ([]os.FileInfo, error) }
File represents a file
File provides a stripped down interface not as complete as os.File but are enough for my use cases. For that reason, some vfs provided in this package are not supercharged to provide correct feedback for os.File func that are not in File (for example Readdirnames is not adapted for filterfs or jailfs)
type VFS ¶
type VFS struct {
// contains filtered or unexported fields
}
VFS encapsulates operations provided to interact with the file-system
VFS functions are to be found in filepath.go and fsutil.go when they are "ported" from the standard library (path/filepath and os respectively).
func NewFilterfs ¶
NewFilterfs creates a new filterfs that relies on a validating function to allow or not access to file-system files depending on their name.
The validating function should, if appropriate, make sure that the forbidden name can be embedded in a full path name (filterfs does not take care of that). For example, disallowing access to hidden files should consider ".name", "folder/.name" and "folder/.name/file"
func NewJailfs ¶
NewJailfs creates a new composite Fs It does not check that root exists nor create it if it doesn't
func NewReadonlyfs ¶ added in v0.3.0
NewReadonlyfs creates a new composite read-only Fs.
func (*VFS) Copy ¶ added in v0.6.0
Copy copies a Reader content to a file within the vfs. dst file and its parent folders are create if they don't exist yet Copy does not prevent nor warn if dst is already existing
func (*VFS) Create ¶
Create creates the named file mode 0666 (before umask) on the given filesystem, truncating it if it already exists. The associated file descriptor has mode os.O_RDWR. If there is an error, it will be of type *os.PathError.
"ported" from standard lib os.Create
func (*VFS) MkdirAll ¶
MkdirAll creates a directory named path on the given filesystem, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.
"ported" from standard lib os.MkdirAll
func (*VFS) Move ¶
Move moves a file or folder to a new location. If destination is in a non existing path, Move creates it first.
func (*VFS) Open ¶
Open opens the named file on the given filesystem for reading. If successful, methods on the returned file can be used for reading. The associated file descriptor has mode os.O_RDONLY. If there is an error, it will be of type *PathError.
"ported" from standard lib os.Open
func (*VFS) RemoveAll ¶
RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil.
"ported" from standard lib os.RemoveAll
func (*VFS) Walk ¶
Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links.