memfs

package
v0.0.0-...-fc5622f Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

memfs implements a simple fake memory FS for Wazero.

The actual implementation of the FS is from github.com/blang/vfs/memfs, this package is just wrapping that for Wazero.

It implements only very small number of functions, because only those were needed for my purposes (that is, running ghostscript with WASI), as ghostscript only calls these.

Feel free to make a PR if you need to implement some other functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemFS

type MemFS struct {
	sys.UnimplementedFS
	// contains filtered or unexported fields
}

MemFS is a memory-only wazero filesystem, implementing just some basic functions.

func New

func New() *MemFS

New creates a new memory filesystem

func (*MemFS) Mkdir

func (m *MemFS) Mkdir(path string, perm fs.FileMode) sys.Errno

func (*MemFS) OpenFile

func (m *MemFS) OpenFile(path string, flag sys.Oflag, perm fs.FileMode) (sys.File, sys.Errno)

OpenFile opens a file as defined in sys.File

func (*MemFS) ReadFile

func (m *MemFS) ReadFile(path string) ([]byte, sys.Errno)

ReadFile is a helper function that returns a content of a file. Errors have the same semantics as wazero errors

func (*MemFS) Stat

func (m *MemFS) Stat(path string) (wasys.Stat_t, sys.Errno)

Stat returns file stat as defined in sys.File

func (m *MemFS) Unlink(path string) sys.Errno

func (*MemFS) WriteFile

func (m *MemFS) WriteFile(path string, content []byte) sys.Errno

WriteFile is a helper function that writes a content to a file. Errors have the same semantics as wazero errors

Jump to

Keyboard shortcuts

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