mapfs

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

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

FS is an in-memory filesystem

func New

func New(opts ...Option) *FS

New creates a new filesystem

func (*FS) CopyFilesUnder

func (m *FS) CopyFilesUnder(dir string) error

func (*FS) Filter

func (m *FS) Filter(skippedFiles []string) (*FS, error)

Filter removes the specified skippedFiles and returns a new FS

func (*FS) FilterFunc added in v0.41.0

func (m *FS) FilterFunc(fn func(path string, d fs.DirEntry) (bool, error)) (*FS, error)

func (*FS) Glob

func (m *FS) Glob(pattern string) ([]string, error)

Glob returns the names of all files matching pattern or nil if there is no matching file. The syntax of patterns is the same as in Match. The pattern may describe hierarchical names such as /usr/*/bin/ed (assuming the Separator is '/').

Glob ignores file system errors such as I/O errors reading directories. The only possible returned error is ErrBadPattern, when pattern is malformed.

func (*FS) MkdirAll

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

MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.

func (*FS) Open

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

Open opens the named file for reading.

func (*FS) ReadDir

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

ReadDir reads the named directory and returns a list of directory entries sorted by filename.

func (*FS) ReadFile

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

ReadFile reads the named file and returns its contents. A successful call returns a nil error, not io.EOF. (Because ReadFile reads the whole file, the expected EOF from the final Read is not treated as an error to be reported.)

The caller is permitted to modify the returned byte slice. This method should return a copy of the underlying data.

func (*FS) Remove

func (m *FS) Remove(path string) error

Remove deletes a file or directory from the filesystem

func (*FS) RemoveAll

func (m *FS) RemoveAll(path string) error

RemoveAll deletes a file or directory and any children if present from the filesystem

func (*FS) Stat

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

Stat returns a FileInfo describing the file.

func (*FS) Sub

func (m *FS) Sub(dir string) (fs.FS, error)

Sub returns an FS corresponding to the subtree rooted at dir.

func (*FS) WriteFile

func (m *FS) WriteFile(path, underlyingPath string) error

WriteFile creates a mapping between path and underlyingPath.

func (*FS) WriteVirtualFile

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

WriteVirtualFile writes the specified bytes to the named file. If the file exists, it will be overwritten.

type Option added in v0.42.0

type Option func(*FS)

func WithUnderlyingRoot added in v0.42.0

func WithUnderlyingRoot(root string) Option

WithUnderlyingRoot returns an option to set the underlying root path for the in-memory filesystem.

Jump to

Keyboard shortcuts

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