writablefs

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

README

writablefs

A minimal superset of io/fs.FS supporting write operations.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalid    = gofs.ErrInvalid    // "invalid argument"
	ErrPermission = gofs.ErrPermission // "permission denied"
	ErrExist      = gofs.ErrExist      // "file already exists"
	ErrNotExist   = gofs.ErrNotExist   // "file does not exist"
	ErrClosed     = gofs.ErrClosed     // "file already closed"
)

Functions

func WalkDir

func WalkDir(fs FS, root string, fn WalkDirFunc) error

WalkDir walks the file tree rooted at root, calling fn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by fn. WalkDir does not follow symbolic links.

Types

type DirEntry

type DirEntry = gofs.DirEntry

type FS

type FS interface {
	// MkdirAll creates a directory named path, along with any necessary parents.
	MkdirAll(path string) error

	// OpenFile opens a file for reading and writing using the given flags.
	OpenFile(path string, flag int) (File, error)

	// ReadDir reads the directory named by path and returns a list of
	// directory entries up to the specified limit. If limit is -1,
	// all entries will be returned.
	ReadDir(path string, limit int, startAfter string) (entries []DirEntry, nextStartAfter string, err error)

	// RemoveAll removes path and any children it contains.
	RemoveAll(path string) error

	// Rename renames (moves) oldpath to newpath.
	Rename(oldpath, newpath string) error

	// Stat returns a FileInfo describing the file.
	Stat(path string) (FileInfo, error)
}

FS is the interface implemented by a writeable file system.

type File

type File interface {
	io.ReadWriter
	io.Seeker
	io.ReaderAt
	io.WriterAt
	io.Closer
	Stat() (FileInfo, error)
	Truncate(size int64) error
}

File is the interface implemented by a writeable file.

type FileInfo

type FileInfo = gofs.FileInfo

type WalkDirFunc

type WalkDirFunc = func(path string, d DirEntry, err error) error

WalkDirFunc is the type of the function called for each file or directory visited by WalkDir.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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