Documentation ¶
Index ¶
- Constants
- Variables
- func Chmod(fs FS, name string, mode FileMode) error
- func ChmodFile(file File, mode FileMode) error
- func Chown(fs FS, name string, uid, gid int) error
- func ChownFile(file File, uid, gid int) error
- func Chtimes(fs FS, name string, atime time.Time, mtime time.Time) error
- func ChtimesFile(file File, atime, mtime time.Time) error
- func Mkdir(fs FS, name string, perm FileMode) error
- func MkdirAll(fs FS, path string, perm FileMode) error
- func ReadAtFile(file File, p []byte, off int64) (n int, err error)
- func ReadFile(fs FS, name string) ([]byte, error)
- func Remove(fs FS, name string) error
- func RemoveAll(fs FS, path string) error
- func Rename(fs FS, oldName, newName string) error
- func SeekFile(file File, offset int64, whence int) (int64, error)
- func Symlink(fs FS, oldname, newname string) error
- func SyncFile(file File) error
- func TruncateFile(file File, size int64) error
- func ValidPath(path string) bool
- func WalkDir(fs FS, root string, fn WalkDirFunc) error
- func WriteAtFile(file File, p []byte, off int64) (n int, err error)
- func WriteFile(file File, p []byte) (n int, err error)
- type ChmodFS
- type ChmoderFile
- type ChownFS
- type ChownerFile
- type ChtimesFS
- type ChtimeserFile
- type CreateFS
- type DirEntry
- type DirReaderFile
- type FS
- type File
- type FileInfo
- type FileMode
- type LinkError
- type LstatFS
- type MkdirAllFS
- type MkdirFS
- type MountFS
- type OpenFileFS
- type PathError
- type ReadDirFS
- type ReadFileFS
- type ReadWriterFile
- type ReaderAtFile
- type RemoveAllFS
- type RemoveFS
- type RenameFS
- type SeekerFile
- type StatFS
- type SubFS
- type SymlinkFS
- type SyncerFile
- type TruncaterFile
- type WalkDirFunc
- type WriterAtFile
Constants ¶
const ( FlagReadOnly int = syscall.O_RDONLY FlagWriteOnly int = syscall.O_WRONLY FlagReadWrite int = syscall.O_RDWR FlagAppend int = syscall.O_APPEND FlagCreate int = syscall.O_CREAT FlagExclusive int = syscall.O_EXCL FlagSync int = syscall.O_SYNC FlagTruncate int = syscall.O_TRUNC )
Flags are bit-wise OR'd with each other in fs.OpenFile(). Exactly one of Read/Write flags must be specified, and any other flags can be OR'd together.
const ( ModeDir = gofs.ModeDir ModeAppend = gofs.ModeAppend ModeExclusive = gofs.ModeExclusive ModeTemporary = gofs.ModeTemporary ModeSymlink = gofs.ModeSymlink ModeDevice = gofs.ModeDevice ModeNamedPipe = gofs.ModeNamedPipe ModeSocket = gofs.ModeSocket ModeSetuid = gofs.ModeSetuid ModeSetgid = gofs.ModeSetgid ModeCharDevice = gofs.ModeCharDevice ModeSticky = gofs.ModeSticky ModeIrregular = gofs.ModeIrregular ModeType = gofs.ModeType ModePerm = gofs.ModePerm )
Mode values are bit-wise OR'd with a file's permissions to form the FileMode. Mirror io/fs.Mode... values.
Variables ¶
var ( ErrInvalid = syscall.EINVAL // TODO update to fs.ErrInvalid, once errors.Is supports it ErrPermission = fs.ErrPermission ErrExist = fs.ErrExist ErrNotExist = fs.ErrNotExist ErrClosed = fs.ErrClosed ErrIsDir = syscall.EISDIR ErrNotDir = syscall.ENOTDIR ErrNotEmpty = syscall.ENOTEMPTY ErrNotImplemented = syscall.ENOSYS SkipDir = fs.SkipDir )
Errors commonly returned by file systems. Mirror their equivalents in the syscall and io/fs packages.
Functions ¶
func Chmod ¶
Chmod attempts to call an optimized fs.Chmod(), falls back to opening the file and running file.Chmod().
func ChmodFile ¶
ChmodFile runs file.Chmod() is available, fails with a not implemented error otherwise.
func Chown ¶
Chown attempts to call an optimized fs.Chown(), falls back to opening the file and running file.Chown().
func ChownFile ¶
ChownFile runs file.Chown() is available, fails with a not implemented error otherwise.
func Chtimes ¶
Chtimes attempts to call an optimized fs.Chtimes(), falls back to opening the file and running file.Chtimes().
func ChtimesFile ¶
ChtimesFile runs file.Chtimes() is available, fails with a not implemented error otherwise.
func MkdirAll ¶
MkdirAll attempts to call an optimized fs.MkdirAll(), falls back to multiple fs.Mkdir() calls.
func ReadAtFile ¶
ReadAtFile runs file.ReadAt() is available, fails with a not implemented error otherwise.
func ReadFile ¶
ReadFile attempts to call an optimized fs.ReadFile(), falls back to io/fs.ReadFile().
func Remove ¶
Remove removes a file with fs.Remove(). Fails with a not implemented error if it's not a RemoveFS.
func RemoveAll ¶
RemoveAll removes files recursively with fs.RemoveAll(). Fails with a not implemented error if it's not a RemoveAllFS.
func Rename ¶
Rename moves files with fs.Rename(). Fails with a not implemented error if it's not a RenameFS.
func SeekFile ¶
SeekFile runs file.Seek() is available, fails with a not implemented error otherwise.
func Symlink ¶
Symlink creates a symlink. Fails with a not implemented error if it's not a SymlinkFS.
func SyncFile ¶
SyncFile runs file.Sync() is available, fails with a not implemented error otherwise.
func TruncateFile ¶
TruncateFile runs file.Truncate() is available, fails with a not implemented error otherwise.
func ValidPath ¶
ValidPath returns true if 'path' is a valid FS path. See io/fs.ValidPath() for details on FS-safe paths.
func WalkDir ¶
func WalkDir(fs FS, root string, fn WalkDirFunc) error
WalkDir recursively scans 'fs' starting at path 'root', calling 'fn' every time a new file or directory is visited.
func WriteAtFile ¶
WriteAtFile runs file.WriteAt() is available, fails with a not implemented error otherwise.
Types ¶
type ChmodFS ¶
ChmodFS is an FS that can change file or directory permissions. Should match the behavior of os.Chmod().
type ChmoderFile ¶
ChmoderFile is a File that supports Chmod() operations.
type ChownFS ¶
ChownFS is an FS that can change file or directory ownership. Should match the behavior of os.Chown().
type ChownerFile ¶
ChownerFile is a File that supports Chown() operations.
type ChtimesFS ¶
ChtimesFS is an FS that can change a file's access and modified timestamps. Should match the behavior of os.Chtimes().
type ChtimeserFile ¶
ChtimeserFile is a File that supports Chtimes() operations.
type DirEntry ¶
DirEntry is an entry read from a directory. Mirrors io/fs.DirEntry.
type DirReaderFile ¶
DirReaderFile is a File that supports ReadDir() operations. Mirrors io/fs.ReadDirFile.
type FS ¶
FS provides access to a file system and its files. It is the minimum functionality required for a file system, and mirrors Go's io/fs.FS interface.
type File ¶
File provides access to a file. Mirrors io/fs.File.
type FileInfo ¶
FileInfo describes a file and is returned by Stat(). Mirrors io/fs.FileInfo.
func Lstat ¶
Lstat stats files and does not follow symlinks. Fails with a not implemented error if it's not a LstatFS.
func LstatOrStat ¶
LstatOrStat attempts to call an optimized fs.LstatOrStat(), fs.Lstat(), or fs.Stat() - whichever is supported first.
type LinkError ¶
LinkError records a file system rename error and the paths that caused it. Mirrors os.LinkError
NOTE: Is not identical to os.LinkError to avoid importing "os". Still resolves errors.Is() calls correctly.
type LstatFS ¶
LstatFS is an FS that can lstat files. Same as Stat, but returns file info of symlinks instead of their target. Should match the behavior of os.Lstat().
type MkdirAllFS ¶
MkdirAllFS is an FS that can make all missing directories in a given path. Should match the behavior of os.MkdirAll().
type MountFS ¶
MountFS is an FS that meshes one or more FS's together. Returns the FS for a file located at 'name' and its 'subPath' inside that FS.
type OpenFileFS ¶
OpenFileFS is an FS that can open files with the given flags and can create with the given permission. Should matche the behavior of os.OpenFile().
type PathError ¶
PathError records a file system or file operation error and the path that caused it. Mirrors io/fs.PathError
type ReadDirFS ¶
ReadDirFS is an FS that can read a directory and return its DirEntry's. Should match the behavior of os.ReadDir().
type ReadFileFS ¶
ReadFileFS is an FS that can read an entire file in one pass. Should match the behavior of os.ReadFile().
type ReadWriterFile ¶
ReadWriterFile is a File that supports Write() operations.
type ReaderAtFile ¶
ReaderAtFile is a File that supports ReadAt() operations.
type RemoveAllFS ¶
RemoveAllFS is an FS that can remove files or directories recursively. Should match the behavior of os.RemoveAll().
type RemoveFS ¶
RemoveFS is an FS that can remove files or empty directories. Should match the behavior of os.Remove().
type RenameFS ¶
RenameFS is an FS that can move files or directories. Should match the behavior of os.Rename().
type SeekerFile ¶
SeekerFile is a File that supports Seek() operations.
type StatFS ¶
StatFS is an FS that can stat files or directories. Should match the behavior of os.Stat().
type SubFS ¶
SubFS is an FS that can return a subset of the current FS. The same effect as `chroot` in a program.
type SymlinkFS ¶
SymlinkFS is an FS that can create symlinks. Should match the behavior of os.Symlink().
type SyncerFile ¶
SyncerFile is a File that supports Sync() operations.
type TruncaterFile ¶
TruncaterFile is a File that supports Truncate() operations.
type WalkDirFunc ¶
type WalkDirFunc = gofs.WalkDirFunc
WalkDirFunc is the type of function called in WalkDir().
type WriterAtFile ¶
WriterAtFile is a File that supports WriteAt() operations.