memfs

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: MIT, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotLink = errors.New("not a link")
	ErrIsDir   = errors.New("is a directory")
)

Functions

This section is empty.

Types

type DirEntry

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

func (*DirEntry) Info

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

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.

func (*DirEntry) IsDir

func (e *DirEntry) IsDir() bool

IsDir reports whether the entry describes a directory.

func (*DirEntry) Name

func (e *DirEntry) Name() string

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".

func (*DirEntry) Type

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

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 Memory

type Memory struct {
	*paths.LocalFilePath
	// contains filtered or unexported fields
}

Memory a very convenient filesystem based on memory files

func New

func New() *Memory

New returns a new Memory filesystem.

func (*Memory) AddFile

func (m *Memory) AddFile(path string, mode fs.FileMode, data []byte) error

AddFile creates a file and writes the given data

func (*Memory) CountDirContents

func (fs *Memory) CountDirContents(name string) (int, error)

CountDirContents: returns the number of files/directories direnctly under a given directory

func (*Memory) MkdirAll

func (m *Memory) MkdirAll(path string, perm fs.FileMode) error

MkdirAll create a new directory and its parents if needed

func (*Memory) Open

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

Open opens the named object for reading.

func (*Memory) ReadDir

func (m *Memory) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir reads the directory and returns a list of DirEntry.

func (*Memory) ReadFile

func (m *Memory) ReadFile(name string) ([]byte, error)

ReadFile reads the whole object into a byte slice.

func (m *Memory) ReadLink(name string) (string, error)

ReadLink returns the destination of the named symbolic link. If there is an error, it will be of type *os.PathError.

func (*Memory) Stat

func (m *Memory) Stat(name string) (fs.FileInfo, error)

Stat returns a FileInfo for the given name.

func (m *Memory) Symlink(target string, path string, perm fs.FileMode) error

func (*Memory) UserHomeDir

func (fs *Memory) UserHomeDir() (string, error)

UserHomeDir returns the current user's home directory.

func (*Memory) WorkDir

func (fs *Memory) WorkDir() string

WorkDir returns the path of working directory

Jump to

Keyboard shortcuts

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