Documentation
¶
Overview ¶
Package fs provides Onix's persistent virtual filesystem.
Every operation uses io/fs paths: names are relative, slash-separated, and cannot escape the mounted root. On native platforms a root is a host directory. In browsers it is a namespace persisted in IndexedDB. In WeChat it is a directory below USER_DATA_PATH.
WriteFile and Rename create missing destination directories. Remove only removes files or empty directories; RemoveAll removes complete directory trees. FileSystem implements io/fs.FS, ReadFileFS, ReadDirFS, and StatFS.
Index ¶
- Variables
- func MkdirAll(name string) error
- func Mount(root string) error
- func Open(name string) (iofs.File, error)
- func ReadDir(name string) ([]iofs.DirEntry, error)
- func ReadFile(name string) ([]byte, error)
- func Remove(name string) error
- func RemoveAll(name string) error
- func Rename(oldName, newName string) error
- func Stat(name string) (iofs.FileInfo, error)
- func WriteFile(name string, data []byte) error
- type FileSystem
- func (f *FileSystem) MkdirAll(name string) error
- func (f *FileSystem) Open(name string) (iofs.File, error)
- func (f *FileSystem) ReadDir(name string) ([]iofs.DirEntry, error)
- func (f *FileSystem) ReadFile(name string) ([]byte, error)
- func (f *FileSystem) Remove(name string) error
- func (f *FileSystem) RemoveAll(name string) error
- func (f *FileSystem) Rename(oldName, newName string) error
- func (f *FileSystem) Stat(name string) (iofs.FileInfo, error)
- func (f *FileSystem) WriteFile(name string, data []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalid = iofs.ErrInvalid ErrNotExist = iofs.ErrNotExist ErrExist = iofs.ErrExist ErrClosed = iofs.ErrClosed ErrNotEmpty = errors.New("directory not empty") )
Functions ¶
Types ¶
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem exposes the same rooted, slash-separated virtual paths on every platform. Browser builds persist entries in IndexedDB.
func Default ¶
func Default() *FileSystem
Default returns the process-wide filesystem used by package-level helpers.
func New ¶
func New(root string) (*FileSystem, error)
New creates an isolated filesystem rooted at root. Names passed to its methods are always virtual io/fs paths, never host absolute paths.
func (*FileSystem) MkdirAll ¶
func (f *FileSystem) MkdirAll(name string) error
func (*FileSystem) Remove ¶
func (f *FileSystem) Remove(name string) error
func (*FileSystem) RemoveAll ¶
func (f *FileSystem) RemoveAll(name string) error
func (*FileSystem) Rename ¶
func (f *FileSystem) Rename(oldName, newName string) error