virtual

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalJSON

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

func UnmarshalJSON

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

Types

type Dir

type Dir struct {
	Path    string
	Mode    fs.FileMode
	ModTime time.Time
	Sys     interface{}
	Entries []fs.DirEntry
	// contains filtered or unexported fields
}

func (*Dir) Close

func (d *Dir) Close() error

func (*Dir) Open

func (d *Dir) Open() fs.File

func (*Dir) Read

func (d *Dir) Read(p []byte) (int, error)

func (*Dir) ReadDir

func (d *Dir) ReadDir(count int) ([]fs.DirEntry, error)

func (*Dir) Stat

func (d *Dir) Stat() (fs.FileInfo, error)

type DirEntry

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

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 Entry

type Entry interface {
	Open() fs.File
}

func From

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

From a file to a virtual file

type File

type File struct {
	Path    string
	Data    []byte
	Mode    fs.FileMode
	ModTime time.Time
	Sys     interface{}
	// contains filtered or unexported fields
}

File struct

func (*File) Close

func (f *File) Close() error

func (*File) Open

func (f *File) Open() fs.File

func (*File) Read

func (f *File) Read(b []byte) (int, error)

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

func (*File) Stat

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

type Map

type Map map[string]Entry

func (Map) Mkdir

func (m Map) Mkdir(dirpath string, perm fs.FileMode) error

Mkdir create a directory. TODO: Mkdir should fail if path.Dir(dirpath) doesn't exist

func (Map) Open

func (m Map) Open(name string) (fs.File, error)

func (Map) Remove

func (m Map) Remove(path string) error

Remove removes a path TODO: Remove should fail if path doesn't exist

func (Map) WriteFile

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

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

type Opener

type Opener func(name string) (fs.File, error)

Opener is a utility function that implements fs.FS

func (Opener) Open

func (fn Opener) Open(name string) (fs.File, error)

Jump to

Keyboard shortcuts

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