Documentation
¶
Overview ¶
Package fs provides filesystem abstractions for asimonim.
Index ¶
- type FileSystem
- type OSFileSystem
- func (f *OSFileSystem) Exists(path string) bool
- func (f *OSFileSystem) MkdirAll(path string, perm fs.FileMode) error
- func (f *OSFileSystem) Open(name string) (fs.File, error)
- func (f *OSFileSystem) ReadDir(name string) ([]fs.DirEntry, error)
- func (f *OSFileSystem) ReadFile(name string) ([]byte, error)
- func (f *OSFileSystem) Remove(name string) error
- func (f *OSFileSystem) Stat(name string) (fs.FileInfo, error)
- func (f *OSFileSystem) TempDir() string
- func (f *OSFileSystem) WriteFile(name string, data []byte, perm fs.FileMode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileSystem ¶
type FileSystem interface {
// File operations
WriteFile(name string, data []byte, perm fs.FileMode) error
ReadFile(name string) ([]byte, error)
Remove(name string) error
// Directory operations
MkdirAll(path string, perm fs.FileMode) error
ReadDir(name string) ([]fs.DirEntry, error)
TempDir() string
// File system queries
Stat(name string) (fs.FileInfo, error)
Exists(path string) bool
// fs.FS compatibility - allows use with fs.WalkDir
Open(name string) (fs.File, error)
}
FileSystem provides an abstraction over filesystem operations. This interface is congruent with bennypowers.dev/cem/internal/platform.FileSystem and bennypowers.dev/mappa/fs.FileSystem to enable duck typing compatibility.
type OSFileSystem ¶
type OSFileSystem struct{}
OSFileSystem implements FileSystem using the standard os package.
func NewOSFileSystem ¶
func NewOSFileSystem() *OSFileSystem
NewOSFileSystem creates a new filesystem that uses the standard os package.
func (*OSFileSystem) Exists ¶
func (f *OSFileSystem) Exists(path string) bool
Exists returns true if the path exists.
func (*OSFileSystem) MkdirAll ¶
func (f *OSFileSystem) MkdirAll(path string, perm fs.FileMode) error
MkdirAll creates a directory path and all parents that do not exist.
func (*OSFileSystem) Open ¶
func (f *OSFileSystem) Open(name string) (fs.File, error)
Open opens the named file for reading.
func (*OSFileSystem) ReadDir ¶
func (f *OSFileSystem) ReadDir(name string) ([]fs.DirEntry, error)
ReadDir reads the named directory and returns its entries.
func (*OSFileSystem) ReadFile ¶
func (f *OSFileSystem) ReadFile(name string) ([]byte, error)
ReadFile reads the entire contents of a file.
func (*OSFileSystem) Remove ¶
func (f *OSFileSystem) Remove(name string) error
Remove deletes the named file or empty directory.
func (*OSFileSystem) Stat ¶
func (f *OSFileSystem) Stat(name string) (fs.FileInfo, error)
Stat returns file information for the named file.
func (*OSFileSystem) TempDir ¶
func (f *OSFileSystem) TempDir() string
TempDir returns the default directory for temporary files.