Documentation ¶
Index ¶
- type FileSystem
- type OsFileSystem
- func (OsFileSystem) Abs(name string) (string, error)
- func (OsFileSystem) Base(name string) string
- func (OsFileSystem) Copy(src, dst string, perm os.FileMode) error
- func (OsFileSystem) Dir(name string) string
- func (OsFileSystem) Exists(path string) bool
- func (OsFileSystem) Ext(name string) string
- func (o *OsFileSystem) FindInParent(name string, maxDirCount int) (string, error)
- func (OsFileSystem) IsAbs(name string) bool
- func (OsFileSystem) Join(elem ...string) string
- func (OsFileSystem) Mkdir(name string, perm os.FileMode) error
- func (OsFileSystem) MkdirAll(path string, perm os.FileMode) error
- func (OsFileSystem) ReadFile(name string) ([]byte, error)
- func (OsFileSystem) RemoveAll(name string) error
- func (OsFileSystem) Stat(name string) (os.FileInfo, error)
- func (OsFileSystem) WalkDir(name string, walkFn fs.WalkDirFunc) error
- func (OsFileSystem) WriteFile(filename string, data []byte, perm os.FileMode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileSystem ¶
type FileSystem interface { Abs(string) (string, error) Base(string) string Copy(string, string, os.FileMode) error Dir(string) string // Exists reports whether the file or folder at path exists. Exists(string) bool // Ext returns the file name extension used by path. Ext(string) string // FindInParent searches for a file in the current directory and then in [maxDirCount] parent directories. FindInParent(string, int) (string, error) Join(elem ...string) string IsAbs(string) bool Mkdir(string, os.FileMode) error MkdirAll(string, os.FileMode) error ReadFile(string) ([]byte, error) RemoveAll(string) error Stat(string) (os.FileInfo, error) WalkDir(string, fs.WalkDirFunc) error WriteFile(string, []byte, os.FileMode) error }
FileSystem is an interface that abstracts file system operations.
type OsFileSystem ¶
type OsFileSystem struct { }
OsFileSystem implements the FileSystem interface using the os package.
func (OsFileSystem) Abs ¶
func (OsFileSystem) Abs(name string) (string, error)
Abs returns an absolute representation of path.
func (OsFileSystem) Base ¶
func (OsFileSystem) Base(name string) string
Base returns the last element of path (basename).
func (OsFileSystem) Copy ¶
func (OsFileSystem) Copy(src, dst string, perm os.FileMode) error
Copy copies recursively a path from src to dst with the given permissions.
func (OsFileSystem) Dir ¶
func (OsFileSystem) Dir(name string) string
Dir returns all but the last element of path, typically the path's directory.
func (OsFileSystem) Exists ¶
func (OsFileSystem) Exists(path string) bool
Exists returns true if the path exists.
func (OsFileSystem) Ext ¶
func (OsFileSystem) Ext(name string) string
Ext returns the file name extension used by path.
func (*OsFileSystem) FindInParent ¶
func (o *OsFileSystem) FindInParent(name string, maxDirCount int) (string, error)
FindInParent searches for a file in the current directory and then in [maxDirCount] parent directories.
func (OsFileSystem) IsAbs ¶
func (OsFileSystem) IsAbs(name string) bool
IsAbs reports whether the path is absolute.
func (OsFileSystem) Join ¶
func (OsFileSystem) Join(elem ...string) string
Join joins any number of path elements into a single path, adding an os-specific separator if necessary.
func (OsFileSystem) Mkdir ¶
func (OsFileSystem) Mkdir(name string, perm os.FileMode) error
MkDir creates a new directory with the specified name and permission bits.
func (OsFileSystem) MkdirAll ¶
func (OsFileSystem) MkdirAll(path string, perm os.FileMode) error
MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error.
func (OsFileSystem) ReadFile ¶
func (OsFileSystem) ReadFile(name string) ([]byte, error)
ReadFile reads the file named by filename and returns the contents.
func (OsFileSystem) RemoveAll ¶
func (OsFileSystem) RemoveAll(name string) error
RemoveAll removes all files and directories in the named directory, including the root.
func (OsFileSystem) Stat ¶
func (OsFileSystem) Stat(name string) (os.FileInfo, error)
Stat returns an os.FileInfo describing the named file or error.
func (OsFileSystem) WalkDir ¶
func (OsFileSystem) WalkDir(name string, walkFn fs.WalkDirFunc) error
WalkDir walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root.