avfs

package
v0.0.0-...-545971b Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirEntry

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

DirEntry is a directory entry.

type DirEntry interface {
	// Name returns the name of the file (or subdirectory) described by the entry.
	// This name is only the final element of the path (the base name), not the entire path.
	// For example, Name would return "hello.go" not "home/gopher/hello.go".
	Name() string
	// IsDir reports whether the entry describes a directory.
	IsDir() bool
	// Type returns the type bits for the entry.
	// The type bits are a subset of the usual FileMode bits, those returned by the FileMode.Type method.
	Type() FileMode
	// Info returns the FileInfo for the file or subdirectory described by the entry.
	// The returned FileInfo may be from the time of the original directory read
	// or from the time of the call to Info. If the file has been removed or renamed
	// since the directory read, Info may return an error satisfying errors.Is(err, ErrNotExist).
	// If the entry denotes a symbolic link, Info reports the information about the link itself,
	// not the link's target.
	Info() (FileInfo, error)
}

func NewDir

func NewDir(name string) *DirEntry

NewDir handler.

func (*DirEntry) Close

func (d *DirEntry) Close() error

Close handler.

func (*DirEntry) Info

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

Info handler.

func (*DirEntry) IsDir

func (d *DirEntry) IsDir() bool

IsDir handler.

func (*DirEntry) Name

func (d *DirEntry) Name() string

Name handler.

func (*DirEntry) Read

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

Read handler.

func (*DirEntry) Stat

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

Stat handler.

func (*DirEntry) Type

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

Type handler.

type FS

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

FS is a simple virtual file system.

func NewFS

func NewFS() *FS

NewFS returns a new virtual filesystem.

func (*FS) AddFile

func (f *FS) AddFile(name string, contents []byte)

AddFile to filesystem.

func (*FS) Open

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

Open opens the named file for reading and returns it as an fs.File.

func (*FS) ReadDir

func (f *FS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir reads and returns the entire named directory.

func (*FS) ReadFile

func (f *FS) ReadFile(name string) ([]byte, error)

ReadFile reads and returns the content of the named file.

type File

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

File is a virtual file.

type File interface {
    Stat() (FileInfo, error)
    Read([]byte) (int, error)
    Close() error
}

func NewFile

func NewFile(name string, contents []byte) *File

NewFile returns a new file.

func (*File) Close

func (f *File) Close() error

Close handler.

func (*File) Info

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

Info handler.

func (*File) Read

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

Read handler.

func (*File) Seek

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

Seek handler.

func (*File) Stat

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

Stat handler.

type FileInfo

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

FileInfo is information on a file.

type FileInfo interface {
    Name() string       // base name of the file
    Size() int64        // length in bytes for regular files; system-dependent for others
    Mode() FileMode     // file mode bits
    ModTime() time.Time // modification time
    IsDir() bool        // abbreviation for Mode().IsDir()
    Sys() interface{}   // underlying data source (can return nil)
}

func (*FileInfo) IsDir

func (f *FileInfo) IsDir() bool

IsDir returns true if a directory.

func (*FileInfo) ModTime

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

ModTime is the modification time.

func (*FileInfo) Mode

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

Mode is the file mode bits.

func (*FileInfo) Name

func (f *FileInfo) Name() string

Name is the base name of the file.

func (*FileInfo) Size

func (f *FileInfo) Size() int64

Size is the length in bytes of the file.

func (*FileInfo) Sys

func (f *FileInfo) Sys() interface{}

Sys returns the file data.

Jump to

Keyboard shortcuts

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