memfs

package
v0.0.0-...-a776223 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RootDir

func RootDir() string

RootDir returns a string representing a root directory. On Unix-like systems this is just /, but on Windows it may be C:\ or some other drive letter.

Types

type MemFS

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

MemFS is a simple in-memory filesystem with a working directory. It's intended mainly for testing.

func MakeMemFS

func MakeMemFS(workingDir string, fileData map[string][]byte) MemFS

MakeMemFS makes a MemFS from the given working directory and file data.

func (MemFS) FileCount

func (fs MemFS) FileCount() int

FileCount returns the total number of files.

func (MemFS) FindWithPrefixAndSuffix

func (fs MemFS) FindWithPrefixAndSuffix(prefix, suffix string) ([]string, error)

FindWithPrefixAndSuffix returns all files whose path matches the given prefix and suffix, in no particular order. The prefix may be absolute or relative (to the working directory).

func (MemFS) MoveFile

func (fs MemFS) MoveFile(oldPath, newPath string) error

MoveFile moves the file at oldPath to newPath. oldPath and newPath may be either absolute or relative (to the working directory). If the file doesn't exist at oldPath, os.ErrNotExist is returned.

func (MemFS) Paths

func (fs MemFS) Paths() []string

Paths returns a list of absolute paths of files in fs in no particular order.

func (MemFS) ReadFile

func (fs MemFS) ReadFile(path string) (data []byte, err error)

ReadFile returns the data of the file at the given path, which may be absolute or relative (to the working directory). If the file doesn't exist, os.ErrNotExist is returned.

func (MemFS) RemoveFile

func (fs MemFS) RemoveFile(path string) ([]byte, error)

RemoveFile removes the file at the given path, which may be absolute or relative (to the working directory). The removed data is returned, or os.ErrNotExist if it doesn't exist.

func (MemFS) WriteFile

func (fs MemFS) WriteFile(path string, data []byte) error

WriteFile sets the data of the file at the given path, which may be absolute or relative (to the working directory). The file may or may not already exist.

Jump to

Keyboard shortcuts

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