fsys

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPathNoDirectory = errors.New("invalid path, path needs a specific directory")

Functions

func EnsureDir

func EnsureDir(ctx context.Context, elems ...string) error

func ValidateDirPath

func ValidateDirPath(path string) error

ValidateDirPath validates if the filepath is a directory

Types

type FS

type FS interface {
	Open(path string) (fs.File, error)

	OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)

	Create(path string) (*os.File, error)

	// Readfile returns the content of a given file
	ReadFile(path string) ([]byte, error)

	// WriteFile writes the data to a file at the given path,
	// it overwrites existing content
	WriteFile(path string, data []byte, perm fs.FileMode) error

	// Calculate a sha256 cheksum on the file
	Sha256(path string) (string, error)

	// Walk walks the file system with the given WalkDirFunc.
	Walk(path string, walkFn fs.WalkDirFunc) error

	// Exists is true if the path exists in the file system.
	Exists(path string) bool

	// Stat returns a FileInfo describing the named file from the file system.
	Stat(path string) (fs.FileInfo, error)

	// Glob returns the list of matching files,
	// emulating https://golang.org/pkg/path/filepath/#Glob
	Glob(pattern string) ([]string, error)

	// MkDir makes a directory.
	Mkdir(path string) error

	// MkDirAll makes a directory path, creating intervening directories.
	MkdirAll(path string) error

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

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

func NewDiskFS

func NewDiskFS(path string) FS

func NewMemFS

func NewMemFS(rootpath string, fs fstest.MapFS) FS

Jump to

Keyboard shortcuts

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