fs

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalid  = iofs.ErrInvalid
	ErrNotExist = iofs.ErrNotExist
	ErrExist    = iofs.ErrExist
	ErrClosed   = iofs.ErrClosed
	ErrNotEmpty = errors.New("directory not empty")
)

Functions

func MkdirAll

func MkdirAll(name string) error

func Mount

func Mount(root string) error

Mount replaces the process-wide filesystem with one rooted at root.

func Open

func Open(name string) (iofs.File, error)

func ReadDir

func ReadDir(name string) ([]iofs.DirEntry, error)

func ReadFile

func ReadFile(name string) ([]byte, error)

func Remove

func Remove(name string) error

func RemoveAll

func RemoveAll(name string) error

func Rename

func Rename(oldName, newName string) error

func Stat

func Stat(name string) (iofs.FileInfo, error)

func WriteFile

func WriteFile(name string, data []byte) error

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) Open

func (f *FileSystem) Open(name string) (iofs.File, error)

func (*FileSystem) ReadDir

func (f *FileSystem) ReadDir(name string) ([]iofs.DirEntry, error)

func (*FileSystem) ReadFile

func (f *FileSystem) ReadFile(name string) ([]byte, 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

func (*FileSystem) Stat

func (f *FileSystem) Stat(name string) (iofs.FileInfo, error)

func (*FileSystem) WriteFile

func (f *FileSystem) WriteFile(name string, data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL