virtfs

package
v0.0.0-...-7217814 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// In WASI, the path separator is always `/`. https://wa.dev/wasi:filesystem
	PathSeparator = '/'
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

type FS struct {
	// contains filtered or unexported fields
}

FS is a simple in-memory file system that allows for read and write access to files. It's inspired by embed.FS from the standard library. It should be safe for concurrent use. Only top level files are supported, directories are not.

func New

func New() *FS

func (*FS) Add

func (f *FS) Add(file *File) error

func (*FS) Get

func (f *FS) Get(name string) (*File, bool)

func (*FS) Open

func (f *FS) Open(name string) (fs.File, error)

func (*FS) WriteFile

func (f *FS) WriteFile(path string, data []byte, _ fs.FileMode) error

type File

type File struct {
	// contains filtered or unexported fields
}

func NewFile

func NewFile(name string, data []byte, opts ...FileOption) *File

func (*File) Close

func (f *File) Close() error

func (*File) IsDir

func (f *File) IsDir() bool

func (*File) ModTime

func (f *File) ModTime() time.Time

func (*File) Mode

func (f *File) Mode() fs.FileMode

func (*File) Name

func (f *File) Name() string

func (*File) Read

func (f *File) Read(p []byte) (n int, err error)

func (*File) ReadOnly

func (f *File) ReadOnly() bool

func (*File) Size

func (f *File) Size() int64

func (*File) Stat

func (f *File) Stat() (fs.FileInfo, error)

func (*File) String

func (f *File) String() string

func (*File) Sys

func (f *File) Sys() any

func (*File) Write

func (f *File) Write(p []byte) (n int, err error)

type FileOption

type FileOption func(*File)

func Writable

func Writable(w io.Writer) FileOption

Jump to

Keyboard shortcuts

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