Documentation
¶
Overview ¶
Package memfs provides a writable in-memory filesystem implementing spidermonkey.WritableFS. It backs tests and fully isolated interpreters: giving two interpreters separate memfs instances isolates their file views completely, with no host filesystem involved.
Paths follow io/fs conventions: slash-separated, unrooted, "." is the root directory. Parent directories are not created implicitly — use Mkdir or MkdirAll first, as a Node-style guest would expect ENOENT otherwise.
Index ¶
- type MemFS
- func (fsys *MemFS) Chmod(name string, mode iofs.FileMode) error
- func (fsys *MemFS) Chtimes(name string, _ time.Time, mtime time.Time) error
- func (fsys *MemFS) Mkdir(name string, perm iofs.FileMode) error
- func (fsys *MemFS) MkdirAll(name string, perm iofs.FileMode) error
- func (fsys *MemFS) Open(name string) (iofs.File, error)
- func (fsys *MemFS) OpenFile(name string, flag int, perm iofs.FileMode) (iofs.File, error)
- func (fsys *MemFS) Remove(name string) error
- func (fsys *MemFS) Rename(oldname, newname string) error
- func (fsys *MemFS) WriteFile(name string, data []byte, perm iofs.FileMode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemFS ¶
type MemFS struct {
// contains filtered or unexported fields
}
MemFS is a writable in-memory filesystem. The zero value is not usable; call NewMemFS. MemFS is safe for concurrent use.
func NewMemFS ¶
func NewMemFS() *MemFS
NewMemFS returns an empty filesystem containing only the root directory.
func (*MemFS) Chmod ¶
Chmod changes the permission bits of name, keeping the file-type bits (iofs.ModeDir, ...) intact. A guest chmod maps here, so a subsequent Stat reflects the new mode.
func (*MemFS) Chtimes ¶
Chtimes sets the modification time of name (the os.Chtimes shape). The access time is accepted for signature compatibility but not stored: io/iofs.FileInfo has no atime accessor, so nothing could ever observe it.
func (*MemFS) OpenFile ¶
OpenFile opens name with OS-style flags (os.O_CREATE, os.O_TRUNC, os.O_APPEND, ...). When the flags request write access the returned file also implements io.Writer. Creating a file requires its parent directory to exist.