kfs

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MPL-2.0 Imports: 9 Imported by: 6

README

kfs

An enhanced go fs implementation

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotImplemented is returned when the file system does not implement an operation
	ErrNotImplemented errNotImplemented
	// ErrTargetOutsideFS is returned when the symlink target is outside the file system
	ErrTargetOutsideFS errTargetOutsideFS
)
View Source
var ErrFileMasked errFileMasked

ErrFileMasked is returned when the file is masked

View Source
var ErrReadOnly errReadOnly

ErrReadOnly is returned when the file is read only

Functions

func Chtimes added in v0.1.2

func Chtimes(fsys fs.FS, name string, atime, mtime time.Time) error

Chtimes changes the time metadata of a file

func FullFilePath added in v0.1.3

func FullFilePath(fsys fs.FS, name string) (string, error)

FullFilePath returns the underlying file path of the named file

If fsys does not implement FullFilePathFS, then FullFilePath returns an error.

func Lstat

func Lstat(fsys fs.FS, name string) (fs.FileInfo, error)

Lstat returns the FileInfo of the named file without following symbolic links

If fsys does not implement LstatFS, then Lstat returns an error.

func ReadLink(fsys fs.FS, name string) (string, error)

ReadLink returns the destination of the named symbolic link.

If fsys does not implement ReadLinkFS, then ReadLink returns an error.

func Remove

func Remove(fsys fs.FS, name string) error

Remove removes a file

func RemoveAll

func RemoveAll(fsys fs.FS, name string) error

RemoveAll removes a file and all children

func WriteFile

func WriteFile(fsys fs.FS, name string, data []byte, perm fs.FileMode) (retErr error)

WriteFile writes a file

If fsys does not implement WriteFS, then OpenFile returns an error.

Types

type ChtimesFS added in v0.1.2

type ChtimesFS interface {
	fs.FS
	// Remove removes a file
	Chtimes(name string, atime, mtime time.Time) error
}

ChtimesFS is a file system that may change file time metadata

type FS

FS implements all the file system operations

func DirFS

func DirFS(dir string) FS

DirFS returns an os.DirFS wrapped by FS

func New

func New(fsys fs.FS, dir string) FS

New creates a new FS

func NewMaskFS

func NewMaskFS(fsys fs.FS, filter FileFilter) FS

NewMaskFS creates a new FS that masks an fs based on a filter

func NewReadOnlyFS

func NewReadOnlyFS(fsys fs.FS) FS

NewReadOnlyFS creates a new FS that is read-only

type File

type File interface {
	fs.File
	io.Writer
}

File is an fs.File that allows writing

func OpenFile

func OpenFile(fsys fs.FS, name string, flag int, mode fs.FileMode) (File, error)

OpenFile opens a file

If fsys does not implement WriteFS, then OpenFile returns an error.

type FileFilter

type FileFilter = func(p string) (bool, error)

FileFilter filters files by file path and dir entry

type FullFilePathFS added in v0.1.3

type FullFilePathFS interface {
	fs.FS
	// FullFilePath returns the underlying file path for a given file name
	//
	// This is intended to serve as an escape hatch for supporting operations
	// that are not generic enough to be handled by a more generic fs
	FullFilePath(name string) (string, error)
}

LstatFS is a file system that can run lstat

type LstatFS

type LstatFS interface {
	fs.FS
	// Lstat returns the FileInfo of the named file without following symbolic
	// links
	Lstat(name string) (fs.FileInfo, error)
}

LstatFS is a file system that can run lstat

type ReadLinkFS

type ReadLinkFS interface {
	fs.FS
	// ReadLink returns the destination of the named symbolic link. Link
	// destinations will always be slash-separated paths relative to the link's
	// directory. The link destination is guaranteed to be a path inside FS.
	ReadLink(name string) (string, error)
}

ReadLinkFS is a file system that can read links

type RemoveAllFS

type RemoveAllFS interface {
	fs.FS
	// RemoveAll removes a file and all children
	RemoveAll(name string) error
}

RemoveAllFS is a file system that may remove files and their children

type RemoveFS

type RemoveFS interface {
	fs.FS
	// Remove removes a file
	Remove(name string) error
}

RemoveFS is a file system that may remove files

type WriteFS

type WriteFS interface {
	fs.FS
	// OpenFile returns an open file
	OpenFile(name string, flag int, mode fs.FileMode) (File, error)
}

WriteFS is a file system that may be read from and written to

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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