virtual

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exclude added in v0.2.6

func Exclude(fsys fs.FS, fn func(path string) bool) fs.FS

func MarshalJSON

func MarshalJSON(file fs.File) ([]byte, error)

func Open added in v0.2.6

func Open(f *File) fs.File

func Print added in v0.2.6

func Print(fsys fs.FS) (string, error)

Print out a virtual filesystem.

func UnmarshalJSON

func UnmarshalJSON(file []byte) (fs.File, error)

Types

type DirEntry

type DirEntry struct {
	Path    string
	Size    int64
	Mode    fs.FileMode
	ModTime time.Time
}

func (*DirEntry) Info

func (e *DirEntry) Info() (fs.FileInfo, error)

func (*DirEntry) IsDir

func (e *DirEntry) IsDir() bool

func (*DirEntry) Name

func (e *DirEntry) Name() string

func (*DirEntry) Type

func (e *DirEntry) Type() fs.FileMode

type FS added in v0.2.5

type FS interface {
	fs.FS
	MkdirAll(path string, perm fs.FileMode) error
	WriteFile(name string, data []byte, perm fs.FileMode) error
	RemoveAll(path string) error
	Sub(path string) (FS, error)
}

type File

type File struct {
	Path    string
	Data    []byte
	Mode    fs.FileMode
	ModTime time.Time
	Entries []fs.DirEntry
}

func From

func From(file fs.File) (entry *File, err error)

From a file to a virtual file

func (*File) Info added in v0.2.5

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

Returns the file info. Implements the fs.DirEntry interface.

func (*File) IsDir added in v0.2.5

func (f *File) IsDir() bool

Returns true if entry is a directory. Implements the fs.DirEntry interface.

func (*File) Name added in v0.2.5

func (f *File) Name() string

Name of the entry. Implements the fs.DirEntry interface.

func (*File) Stamp added in v0.2.6

func (f *File) Stamp() (stamp string, err error)

Stamp helps quickly determine if a file has changed.

func (*File) Type added in v0.2.5

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

Returns the type of entry. Implements the fs.DirEntry interface.

type Map

type Map map[string]*File

func (Map) MkdirAll added in v0.2.5

func (fsys Map) MkdirAll(path string, perm fs.FileMode) error

Mkdir create a directory.

func (Map) Open

func (fsys Map) Open(path string) (fs.File, error)

func (Map) RemoveAll added in v0.2.5

func (fsys Map) RemoveAll(path string) error

Remove removes a path

func (Map) Sub added in v0.2.5

func (fsys Map) Sub(dir string) (FS, error)

Sub returns a submap

func (Map) WriteFile

func (fsys Map) WriteFile(path string, data []byte, perm fs.FileMode) error

WriteFile writes a file

type OS added in v0.2.5

type OS string

OS creates a new OS filesystem rooted at the given directory. TODO: create an os_windows for opening on multiple drives with the same API: https://github.com/golang/go/issues/44279#issuecomment-955766528

func (OS) MkdirAll added in v0.2.5

func (dir OS) MkdirAll(path string, perm fs.FileMode) error

func (OS) Open added in v0.2.5

func (dir OS) Open(name string) (fs.File, error)

func (OS) RemoveAll added in v0.2.5

func (dir OS) RemoveAll(path string) error

func (OS) Sub added in v0.2.5

func (dir OS) Sub(subdir string) (FS, error)

func (OS) WriteFile added in v0.2.5

func (dir OS) WriteFile(name string, data []byte, perm fs.FileMode) error

type Tree added in v0.2.5

type Tree map[string]*File

func (Tree) MkdirAll added in v0.2.5

func (t Tree) MkdirAll(path string, perm fs.FileMode) error

Mkdir create a directory.

func (Tree) Open added in v0.2.5

func (fsys Tree) Open(path string) (fs.File, error)

func (Tree) RemoveAll added in v0.2.5

func (t Tree) RemoveAll(path string) error

Remove removes a path

func (Tree) Sub added in v0.2.5

func (t Tree) Sub(dir string) (FS, error)

Sub returns a subtree

func (Tree) WriteFile added in v0.2.5

func (t Tree) WriteFile(path string, data []byte, perm fs.FileMode) error

WriteFile writes a file TODO: WriteFile should fail if path.Dir(name) doesn't exist

Jump to

Keyboard shortcuts

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