{"modulePath":"github.com/hack-pad/hackpadfs","version":"v0.2.4","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package hackpadfs\n\nPackage hackpadfs defines many essential file and file system interfaces as well as helpers for use with the standard library's 'io/fs' package.\n\n## Constants\n\n```go\nconst (\n\tFlagReadOnly  int = syscall.O_RDONLY\n\tFlagWriteOnly int = syscall.O_WRONLY\n\tFlagReadWrite int = syscall.O_RDWR\n\n\tFlagAppend    int = syscall.O_APPEND\n\tFlagCreate    int = syscall.O_CREAT\n\tFlagExclusive int = syscall.O_EXCL\n\tFlagSync      int = syscall.O_SYNC\n\tFlagTruncate  int = syscall.O_TRUNC\n)\n```\nFlags 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.\n\n```go\nconst (\n\tModeDir        = gofs.ModeDir\n\tModeAppend     = gofs.ModeAppend\n\tModeExclusive  = gofs.ModeExclusive\n\tModeTemporary  = gofs.ModeTemporary\n\tModeSymlink    = gofs.ModeSymlink\n\tModeDevice     = gofs.ModeDevice\n\tModeNamedPipe  = gofs.ModeNamedPipe\n\tModeSocket     = gofs.ModeSocket\n\tModeSetuid     = gofs.ModeSetuid\n\tModeSetgid     = gofs.ModeSetgid\n\tModeCharDevice = gofs.ModeCharDevice\n\tModeSticky     = gofs.ModeSticky\n\tModeIrregular  = gofs.ModeIrregular\n\n\tModeType = gofs.ModeType\n\tModePerm = gofs.ModePerm\n)\n```\nMode values are bit-wise OR'd with a file's permissions to form the FileMode. Mirror io/fs.Mode... values.\n\n## Variables\n\n```go\nvar (\n\tErrInvalid    = syscall.EINVAL // TODO update to fs.ErrInvalid, once errors.Is supports it\n\tErrPermission = fs.ErrPermission\n\tErrExist      = fs.ErrExist\n\tErrNotExist   = fs.ErrNotExist\n\tErrClosed     = fs.ErrClosed\n\n\tErrIsDir          = syscall.EISDIR\n\tErrNotDir         = syscall.ENOTDIR\n\tErrNotEmpty       = syscall.ENOTEMPTY\n\tErrNotImplemented = syscall.ENOSYS\n\n\tSkipDir = fs.SkipDir\n)\n```\nErrors commonly returned by file systems. Mirror their equivalents in the syscall and io/fs packages.\n\n## Functions\n\n```go\nfunc Chmod(fs FS, name string, mode FileMode) error\n```\nChmod attempts to call an optimized fs.Chmod(), falls back to opening the file and running file.Chmod().\n\n```go\nfunc ChmodFile(file File, mode FileMode) error\n```\nChmodFile runs file.Chmod() is available, fails with a not implemented error otherwise.\n\n```go\nfunc Chown(fs FS, name string, uid, gid int) error\n```\nChown attempts to call an optimized fs.Chown(), falls back to opening the file and running file.Chown().\n\n```go\nfunc ChownFile(file File, uid, gid int) error\n```\nChownFile runs file.Chown() is available, fails with a not implemented error otherwise.\n\n```go\nfunc Chtimes(fs FS, name string, atime time.Time, mtime time.Time) error\n```\nChtimes attempts to call an optimized fs.Chtimes(), falls back to opening the file and running file.Chtimes().\n\n```go\nfunc ChtimesFile(file File, atime, mtime time.Time) error\n```\nChtimesFile runs file.Chtimes() is available, fails with a not implemented error otherwise.\n\n```go\nfunc Mkdir(fs FS, name string, perm FileMode) error\n```\nMkdir creates a directory. Fails with a not implemented error if it's not a MkdirFS.\n\n```go\nfunc MkdirAll(fs FS, path string, perm FileMode) error\n```\nMkdirAll attempts to call an optimized fs.MkdirAll(), falls back to multiple fs.Mkdir() calls.\n\n```go\nfunc ReadAtFile(file File, p []byte, off int64) (n int, err error)\n```\nReadAtFile runs file.ReadAt() is available, fails with a not implemented error otherwise.\n\n```go\nfunc ReadFile(fs FS, name string) ([]byte, error)\n```\nReadFile attempts to call an optimized fs.ReadFile(), falls back to io/fs.ReadFile().\n\n```go\nfunc Remove(fs FS, name string) error\n```\nRemove removes a file with fs.Remove(). Fails with a not implemented error if it's not a RemoveFS.\n\n```go\nfunc RemoveAll(fs FS, path string) error\n```\nRemoveAll attempts to call an optimized fs.RemoveAll(), falls back to removing files and directories recursively.\n\n```go\nfunc Rename(fs FS, oldName, newName string) error\n```\nRename moves files with fs.Rename(). Fails with a not implemented error if it's not a RenameFS.\n\n```go\nfunc SeekFile(file File, offset int64, whence int) (int64, error)\n```\nSeekFile runs file.Seek() is available, fails with a not implemented error otherwise.\n\n```go\nfunc Symlink(fs FS, oldname, newname string) error\n```\nSymlink creates a symlink. Fails with a not implemented error if it's not a SymlinkFS.\n\n```go\nfunc SyncFile(file File) error\n```\nSyncFile runs file.Sync() is available, fails with a not implemented error otherwise.\n\n```go\nfunc TruncateFile(file File, size int64) error\n```\nTruncateFile runs file.Truncate() is available, fails with a not implemented error otherwise.\n\n```go\nfunc ValidPath(path string) bool\n```\nValidPath returns true if 'path' is a valid FS path. See io/fs.ValidPath() for details on FS-safe paths.\n\n```go\nfunc WalkDir(fs FS, root string, fn WalkDirFunc) error\n```\nWalkDir recursively scans 'fs' starting at path 'root', calling 'fn' every time a new file or directory is visited.\n\n```go\nfunc WriteAtFile(file File, p []byte, off int64) (n int, err error)\n```\nWriteAtFile runs file.WriteAt() is available, fails with a not implemented error otherwise.\n\n```go\nfunc WriteFile(file File, p []byte) (n int, err error)\n```\nWriteFile runs file.Write() is available, fails with a not implemented error otherwise.\n\n```go\nfunc WriteFullFile(fs FS, name string, data []byte, perm FileMode) error\n```\nWriteFullFile attempts to call an optimized fs.WriteFile(), falls back to fs.OpenFile() with file.Write().\n\n## Types\n\n```go\ntype ChmodFS interface {\n\tFS\n\tChmod(name string, mode FileMode) error\n}\n```\nChmodFS is an FS that can change file or directory permissions. Should match the behavior of os.Chmod().\n\n```go\ntype ChmoderFile interface {\n\tFile\n\tChmod(mode FileMode) error\n}\n```\nChmoderFile is a File that supports Chmod() operations.\n\n```go\ntype ChownFS interface {\n\tFS\n\tChown(name string, uid, gid int) error\n}\n```\nChownFS is an FS that can change file or directory ownership. Should match the behavior of os.Chown().\n\n```go\ntype ChownerFile interface {\n\tFile\n\tChown(uid, gid int) error\n}\n```\nChownerFile is a File that supports Chown() operations.\n\n```go\ntype ChtimesFS interface {\n\tFS\n\tChtimes(name string, atime time.Time, mtime time.Time) error\n}\n```\nChtimesFS is an FS that can change a file's access and modified timestamps. Should match the behavior of os.Chtimes().\n\n```go\ntype ChtimeserFile interface {\n\tFile\n\tChtimes(atime time.Time, mtime time.Time) error\n}\n```\nChtimeserFile is a File that supports Chtimes() operations.\n\n```go\ntype CreateFS interface {\n\tFS\n\tCreate(name string) (File, error)\n}\n```\nCreateFS is an FS that can create files. Should match the behavior of os.Create().\n\n```go\ntype DirEntry = gofs.DirEntry\n```\nDirEntry is an entry read from a directory. Mirrors io/fs.DirEntry.\n\n```go\nfunc ReadDir(fs FS, name string) ([]DirEntry, error)\n```\nReadDir attempts to call an optimized fs.ReadDir(), falls back to io/fs.ReadDir().\n\n```go\nfunc ReadDirFile(file File, n int) ([]DirEntry, error)\n```\nReadDirFile runs file.ReadDir() is available, fails with a not implemented error otherwise.\n\n```go\ntype DirReaderFile interface {\n\tFile\n\tReadDir(n int) ([]DirEntry, error)\n}\n```\nDirReaderFile is a File that supports ReadDir() operations. Mirrors io/fs.ReadDirFile.\n\n```go\ntype FS = gofs.FS\n```\nFS 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.\n\n```go\nfunc Sub(fs FS, dir string) (FS, error)\n```\nSub attempts to call an optimized fs.Sub() if available. Falls back to a small MountFS implementation.\n\n```go\ntype File = gofs.File\n```\nFile provides access to a file. Mirrors io/fs.File.\n\n```go\nfunc Create(fs FS, name string) (File, error)\n```\nCreate attempts to call an optimized fs.Create() if available, falls back to OpenFile() with create flags.\n\n```go\nfunc OpenFile(fs FS, name string, flag int, perm FileMode) (File, error)\n```\nOpenFile attempts to call fs.Open() or fs.OpenFile() if available. Fails with a not implemented error otherwise.\n\n```go\ntype FileInfo = gofs.FileInfo\n```\nFileInfo describes a file and is returned by Stat(). Mirrors io/fs.FileInfo.\n\n```go\nfunc Lstat(fs FS, name string) (FileInfo, error)\n```\nLstat stats files and does not follow symlinks. Fails with a not implemented error if it's not a LstatFS.\n\n```go\nfunc LstatOrStat(fs FS, name string) (FileInfo, error)\n```\nLstatOrStat attempts to call an optimized fs.LstatOrStat(), fs.Lstat(), or fs.Stat() - whichever is supported first.\n\n```go\nfunc Stat(fs FS, name string) (FileInfo, error)\n```\nStat attempts to call an optimized fs.Stat(), falls back to fs.Open() and file.Stat().\n\n```go\ntype FileMode = gofs.FileMode\n```\nFileMode represents a file's mode and permission bits. Mirrors io/fs.FileMode.\n\n```go\ntype LinkError struct {\n\tErr error\n\tOp  string\n\tOld string\n\tNew string\n}\n```\nLinkError records a file system rename error and the paths that caused it. Mirrors os.LinkError\n\nNOTE: Is not identical to os.LinkError to avoid importing \"os\". Still resolves errors.Is() calls correctly.\n\n```go\nfunc (e *LinkError) Error() string\n```\n\n```go\nfunc (e *LinkError) Unwrap() error\n```\nUnwrap supports errors.Unwrap().\n\n```go\ntype LstatFS interface {\n\tFS\n\tLstat(name string) (FileInfo, error)\n}\n```\nLstatFS 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().\n\n```go\ntype MkdirAllFS interface {\n\tFS\n\tMkdirAll(path string, perm FileMode) error\n}\n```\nMkdirAllFS is an FS that can make all missing directories in a given path. Should match the behavior of os.MkdirAll().\n\n```go\ntype MkdirFS interface {\n\tFS\n\tMkdir(name string, perm FileMode) error\n}\n```\nMkdirFS is an FS that can make directories. Should match the behavior of os.Mkdir().\n\n```go\ntype MountFS interface {\n\tFS\n\tMount(name string) (mountFS FS, subPath string)\n}\n```\nMountFS 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.\n\n```go\ntype OpenFileFS interface {\n\tFS\n\tOpenFile(name string, flag int, perm FileMode) (File, error)\n}\n```\nOpenFileFS 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().\n\n```go\ntype PathError = fs.PathError\n```\nPathError records a file system or file operation error and the path that caused it. Mirrors io/fs.PathError\n\n```go\ntype ReadDirFS interface {\n\tFS\n\tReadDir(name string) ([]DirEntry, error)\n}\n```\nReadDirFS is an FS that can read a directory and return its DirEntry's. Should match the behavior of os.ReadDir().\n\n```go\ntype ReadFileFS interface {\n\tFS\n\tReadFile(name string) ([]byte, error)\n}\n```\nReadFileFS is an FS that can read an entire file in one pass. Should match the behavior of os.ReadFile().\n\n```go\ntype ReadWriterFile interface {\n\tFile\n\tio.Writer\n}\n```\nReadWriterFile is a File that supports Write() operations.\n\n```go\ntype ReaderAtFile interface {\n\tFile\n\tio.ReaderAt\n}\n```\nReaderAtFile is a File that supports ReadAt() operations.\n\n```go\ntype RemoveAllFS interface {\n\tFS\n\tRemoveAll(name string) error\n}\n```\nRemoveAllFS is an FS that can remove files or directories recursively. Should match the behavior of os.RemoveAll().\n\n```go\ntype RemoveFS interface {\n\tFS\n\tRemove(name string) error\n}\n```\nRemoveFS is an FS that can remove files or empty directories. Should match the behavior of os.Remove().\n\n```go\ntype RenameFS interface {\n\tFS\n\tRename(oldname, newname string) error\n}\n```\nRenameFS is an FS that can move files or directories. Should match the behavior of os.Rename().\n\n```go\ntype SeekerFile interface {\n\tFile\n\tio.Seeker\n}\n```\nSeekerFile is a File that supports Seek() operations.\n\n```go\ntype StatFS interface {\n\tFS\n\tStat(name string) (FileInfo, error)\n}\n```\nStatFS is an FS that can stat files or directories. Should match the behavior of os.Stat().\n\n```go\ntype SubFS interface {\n\tFS\n\tSub(dir string) (FS, error)\n}\n```\nSubFS is an FS that can return a subset of the current FS. The same effect as \\`chroot\\` in a program.\n\n```go\ntype SymlinkFS interface {\n\tFS\n\tSymlink(oldname, newname string) error\n}\n```\nSymlinkFS is an FS that can create symlinks. Should match the behavior of os.Symlink().\n\n```go\ntype SyncerFile interface {\n\tFile\n\tSync() error\n}\n```\nSyncerFile is a File that supports Sync() operations.\n\n```go\ntype TruncaterFile interface {\n\tFile\n\tTruncate(size int64) error\n}\n```\nTruncaterFile is a File that supports Truncate() operations.\n\n```go\ntype WalkDirFunc = gofs.WalkDirFunc\n```\nWalkDirFunc is the type of function called in WalkDir().\n\n```go\ntype WriteFileFS interface {\n\tFS\n\tWriteFile(name string, data []byte, perm FileMode) error\n}\n```\nWriteFileFS is an FS that can write an entire file in one pass. Should match the behavior of os.WriteFile().\n\n```go\ntype WriterAtFile interface {\n\tFile\n\tio.WriterAt\n}\n```\nWriterAtFile is a File that supports WriteAt() operations.\n\n","path":"github.com/hack-pad/hackpadfs","name":"hackpadfs","synopsis":"Package hackpadfs defines many essential file and file system interfaces as well as helpers for use with the standard library's 'io/fs' package.","isRedistributable":true}
