Documentation
¶
Overview ¶
Package memfs implements an in-memory FileSystem suitable for use as the default backing store of a Bash sandbox. It supports regular files, directories, hard links (via shared content), symbolic links, permissions, mtime, and lazy file providers (see fs.FileInit).
All operations are protected by an internal sync.RWMutex. The implementation aims for byte-identical behavior with the just-bash TS in-memory FS where the surfaces overlap.
Index ¶
- Constants
- type FS
- func (m *FS) AllPaths() []string
- func (m *FS) AppendFile(name string, data []byte, perm os.FileMode) error
- func (m *FS) Chmod(name string, mode os.FileMode) error
- func (m *FS) Chtimes(name string, atime, mtime time.Time) error
- func (m *FS) Create(name string) (gobashfs.File, error)
- func (m *FS) Link(oldpath, newpath string) error
- func (m *FS) Lstat(name string) (os.FileInfo, error)
- func (m *FS) Mkdir(name string, perm os.FileMode) error
- func (m *FS) MkdirAll(name string, perm os.FileMode) error
- func (m *FS) Open(name string) (iofs.File, error)
- func (m *FS) OpenFile(name string, flag int, perm os.FileMode) (gobashfs.File, error)
- func (m *FS) ReadDir(name string) ([]iofs.DirEntry, error)
- func (m *FS) ReadFile(name string) ([]byte, error)
- func (m *FS) Readlink(name string) (string, error)
- func (m *FS) Realpath(name string) (string, error)
- func (m *FS) Remove(name string) error
- func (m *FS) RemoveAll(name string) error
- func (m *FS) Rename(oldpath, newpath string) error
- func (m *FS) Seed(files map[string]gobashfs.FileInit) error
- func (m *FS) SetMaxBytes(limit int64) error
- func (m *FS) Stat(name string) (os.FileInfo, error)
- func (m *FS) Symlink(target, linkpath string) error
- func (m *FS) WriteFile(name string, data []byte, perm os.FileMode) error
Constants ¶
const MaxFollow = gobashfs.MaxSymlinkDepth
MaxFollow caps symlink traversal at the FS layer. Matches fs.MaxSymlinkDepth.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS is the in-memory FileSystem.
func (*FS) AllPaths ¶
AllPaths returns every regular file path in the FS. Used by glob expansion's getAllPaths in Phase 6.
func (*FS) AppendFile ¶
AppendFile appends data to name, creating it if necessary.
func (*FS) Link ¶
Link creates a hard link at newpath pointing to the same content as oldpath. The two paths thereafter share the same content slice (writes through either become visible at the other).
func (*FS) ReadDir ¶
ReadDir lists the entries in name (a directory). Result is sorted by name to match the io/fs.ReadDirFS contract.
func (*FS) Realpath ¶
Realpath canonicalizes name: cleans the path, follows symlinks, and returns the absolute path to the underlying object. It is *not* an existence check by itself, but a non-existent path returns ErrNotExist.
func (*FS) Seed ¶
Seed loads the given FileInit map into the FS, creating parent directories as needed. It is intended for use by the gobash New() constructor when honoring BashOptions.Files.
func (*FS) SetMaxBytes ¶
SetMaxBytes sets a total regular-file content budget. Zero permits only empty files.