Documentation ¶
Index ¶
- Variables
- func CopyFS(dest, src fs.FS, root string) error
- func Glob(fsys fs.FS, pattern string) (matches []string, err error)
- func MkdirAll(fsys fs.FS, dir string, mode fs.FileMode) error
- func ReadFile(fsys fs.FS, name string) ([]byte, error)
- func RemoveAll(fsys fs.FS, path string) error
- func RemoveFile(fsys fs.FS, name string) error
- func ValidPath(name string) bool
- func WalkDir(fsys fs.FS, root string, fn fs.WalkDirFunc) error
- func WriteFile(fsys fs.FS, name string, p []byte, mode fs.FileMode) (n int, err error)
- type DirEntryDelegator
- type DirEntryValues
- type FSDelegator
- func (d *FSDelegator) CreateFile(name string, mode fs.FileMode) (WriterFile, error)
- func (d *FSDelegator) Glob(pattern string) ([]string, error)
- func (d *FSDelegator) MkdirAll(dir string, mode fs.FileMode) error
- func (d *FSDelegator) Open(name string) (fs.File, error)
- func (d *FSDelegator) ReadDir(name string) ([]fs.DirEntry, error)
- func (d *FSDelegator) ReadFile(name string) ([]byte, error)
- func (d *FSDelegator) RemoveAll(path string) error
- func (d *FSDelegator) RemoveFile(name string) error
- func (d *FSDelegator) Stat(name string) (fs.FileInfo, error)
- func (d *FSDelegator) Sub(name string) (fs.FS, error)
- func (d *FSDelegator) WriteFile(name string, p []byte, mode fs.FileMode) (int, error)
- type FileDelegator
- type FileInfoDelegator
- type FileInfoValues
- type OpenFSDelegator
- type RemoveFileFS
- type WriteFileFS
- type WriterFile
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotImplemented "not implemented" ErrNotImplemented = errors.New("not implemented") )
Functions ¶
func CopyFS ¶
CopyFS walks the specified root directory on src and copies directories and files to dest filesystem.
func MkdirAll ¶
MkdirAll creates the named directory. If the filesystem implements WriteFileFS calls fsys.MkdirAll otherwise returns a PathError.
func RemoveAll ¶
RemoveAll removes path and any children it contains. If the filesystem implements RemoveFileFS calls fsys.RemoveAll otherwise return a PathError.
func RemoveFile ¶
RemoveFile removes the specified named file. If the filesystem implements RemoveFileFS calls fsys.RemoveFile otherwise return a PathError.
Types ¶
type DirEntryDelegator ¶
type DirEntryDelegator struct { Values DirEntryValues InfoFunc func() (fs.FileInfo, error) }
DirEntryDelegator implements fs.DirEntry.
func DelegateDirEntry ¶
func DelegateDirEntry(d fs.DirEntry) *DirEntryDelegator
DelegateDirEntry returns a DirEntryDelegator delegates the functions of the specified DirEntry.
func (*DirEntryDelegator) Info ¶
func (d *DirEntryDelegator) Info() (fs.FileInfo, error)
Info calls d.InfoFunc if the function is set otherwise returns d.Values.Info.
func (*DirEntryDelegator) IsDir ¶
func (d *DirEntryDelegator) IsDir() bool
IsDir returns d.Values.IsDir.
func (*DirEntryDelegator) Name ¶
func (d *DirEntryDelegator) Name() string
Name returns d.Values.Name.
func (*DirEntryDelegator) Type ¶
func (d *DirEntryDelegator) Type() fs.FileMode
Type returns d.Values.Type.
type DirEntryValues ¶
DirEntryValues holds values for fs.DirEntry.
type FSDelegator ¶
type FSDelegator struct { OpenFunc func(name string) (fs.File, error) ReadDirFunc func(name string) ([]fs.DirEntry, error) ReadFileFunc func(name string) ([]byte, error) GlobFunc func(pattern string) ([]string, error) StatFunc func(name string) (fs.FileInfo, error) SubFunc func(dir string) (fs.FS, error) MkdirAllFunc func(dir string, mode fs.FileMode) error CreateFileFunc func(name string, mode fs.FileMode) (WriterFile, error) WriteFileFunc func(name string, p []byte, mode fs.FileMode) (int, error) RemoveFileFunc func(name string) error RemoveAllFunc func(path string) error }
FSDelegator implements all filesystem interfaces in io/fs and WriteFileFS.
func DelegateFS ¶
func DelegateFS(fsys fs.FS) *FSDelegator
DelegateFS returns a FSDelegator delegates the functions of the specified filesystem. If you want to delegate an open only filesystem like os.DirFS(dir string) use DelegateOpenFS instead.
func (*FSDelegator) CreateFile ¶
func (d *FSDelegator) CreateFile(name string, mode fs.FileMode) (WriterFile, error)
CreateFile calls CreateFileFunc(name).
func (*FSDelegator) Glob ¶
func (d *FSDelegator) Glob(pattern string) ([]string, error)
Glob calls GlobFunc(name).
func (*FSDelegator) MkdirAll ¶
func (d *FSDelegator) MkdirAll(dir string, mode fs.FileMode) error
MkdirAll calls MkdirAllFunc(dir).
func (*FSDelegator) Open ¶
func (d *FSDelegator) Open(name string) (fs.File, error)
Open calls OpenFunc(name).
func (*FSDelegator) ReadDir ¶
func (d *FSDelegator) ReadDir(name string) ([]fs.DirEntry, error)
ReadDir calls ReadDirFunc(name).
func (*FSDelegator) ReadFile ¶
func (d *FSDelegator) ReadFile(name string) ([]byte, error)
ReadFile calls ReadFileFunc(name).
func (*FSDelegator) RemoveAll ¶
func (d *FSDelegator) RemoveAll(path string) error
RemoveAll calls RemoveAllFunc(name).
func (*FSDelegator) RemoveFile ¶
func (d *FSDelegator) RemoveFile(name string) error
RemoveFile calls RemoveFileFunc(name).
func (*FSDelegator) Stat ¶
func (d *FSDelegator) Stat(name string) (fs.FileInfo, error)
Stat calls StatFunc(name).
type FileDelegator ¶
type FileDelegator struct { StatFunc func() (fs.FileInfo, error) ReadFunc func(p []byte) (int, error) CloseFunc func() error ReadDirFunc func(n int) ([]fs.DirEntry, error) WriteFunc func(p []byte) (int, error) }
FileDelegator implements fs.File, fs.ReadDirFile and WriterFile interface.
func DelegateFile ¶
func DelegateFile(f fs.File) *FileDelegator
DelegateFile returns a FileDelegator delegates the functions of the specified file.
func (*FileDelegator) Read ¶
func (f *FileDelegator) Read(p []byte) (int, error)
Read calls ReadFunc(p).
func (*FileDelegator) ReadDir ¶
func (f *FileDelegator) ReadDir(n int) ([]fs.DirEntry, error)
ReadDir calls ReadDirFunc(n).
type FileInfoDelegator ¶
type FileInfoDelegator struct {
Values FileInfoValues
}
FileInfoDelegator implements fs.FileInfo.
func DelegateFileInfo ¶
func DelegateFileInfo(info fs.FileInfo) *FileInfoDelegator
DelegateFileInfo returns a FileInfoDelegator delegates the functions of the specified FileInfo.
func (*FileInfoDelegator) IsDir ¶
func (d *FileInfoDelegator) IsDir() bool
IsDir returns d.Values.IsDir.
func (*FileInfoDelegator) ModTime ¶
func (d *FileInfoDelegator) ModTime() time.Time
ModTime returns d.Values.ModTime.
func (*FileInfoDelegator) Mode ¶
func (d *FileInfoDelegator) Mode() fs.FileMode
Mode returns d.Values.Mode.
func (*FileInfoDelegator) Name ¶
func (d *FileInfoDelegator) Name() string
Name returns d.Values.Name.
func (*FileInfoDelegator) Size ¶
func (d *FileInfoDelegator) Size() int64
Size returns d.Values.Size.
func (*FileInfoDelegator) Sys ¶
func (d *FileInfoDelegator) Sys() interface{}
Sys returns d.Values.Sys.
type FileInfoValues ¶
type FileInfoValues struct { Name string Size int64 Mode fs.FileMode ModTime time.Time IsDir bool Sys interface{} }
FileInfoValues holds values for fs.FileInfo.
type OpenFSDelegator ¶
OpenFSDelegator implements fs.FS interface.
func DelegateOpenFS ¶
func DelegateOpenFS(fsys fs.FS) *OpenFSDelegator
DelegateOpenFS returns a OpenFSDelegator delegates fsys.Open.
type RemoveFileFS ¶
RemoveFileFS is the interface implemented by a filesystem that provides an implementation of RemoveFile.
type WriteFileFS ¶
type WriteFileFS interface { fs.FS MkdirAll(dir string, mode fs.FileMode) error CreateFile(name string, mode fs.FileMode) (WriterFile, error) WriteFile(name string, p []byte, mode fs.FileMode) (n int, err error) }
WriteFileFS is the interface implemented by a filesystem that provides an optimized implementation of MkdirAll, CreateFile, WriteFile.
type WriterFile ¶
WriterFile is a file that provides an implementation fs.File and io.Writer.
func CreateFile ¶
CreateFile creates the named file. If the filesystem implements WriteFileFS calls fsys.CreateFile otherwise returns a PathError.
Directories ¶
Path | Synopsis |
---|---|
Package memfs provides an in-memory filesystem.
|
Package memfs provides an in-memory filesystem. |
Package osfs provides a filesystem for the OS.
|
Package osfs provides a filesystem for the OS. |
Package wfstest implements support for testing implementations and users of file systems.
|
Package wfstest implements support for testing implementations and users of file systems. |