fsys

package
v0.0.0-...-40d8c5d Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSystem

type FileSystem interface {
	Abs(string) (string, error)
	Base(string) string
	Copy(string, string, os.FileMode) error
	Dir(string) string
	// Exists reports whether the file or folder at path exists.
	Exists(string) bool
	// Ext returns the file name extension used by path.
	Ext(string) string
	// FindInParent searches for a file in the current directory and then in [maxDirCount] parent directories.
	FindInParent(string, int) (string, error)
	Join(elem ...string) string
	IsAbs(string) bool
	Mkdir(string, os.FileMode) error
	MkdirAll(string, os.FileMode) error
	ReadFile(string) ([]byte, error)
	RemoveAll(string) error
	Stat(string) (os.FileInfo, error)
	WalkDir(string, fs.WalkDirFunc) error
	WriteFile(string, []byte, os.FileMode) error
}

FileSystem is an interface that abstracts file system operations.

type OsFileSystem

type OsFileSystem struct {
}

OsFileSystem implements the FileSystem interface using the os package.

func (OsFileSystem) Abs

func (OsFileSystem) Abs(name string) (string, error)

Abs returns an absolute representation of path.

func (OsFileSystem) Base

func (OsFileSystem) Base(name string) string

Base returns the last element of path (basename).

func (OsFileSystem) Copy

func (OsFileSystem) Copy(src, dst string, perm os.FileMode) error

Copy copies recursively a path from src to dst with the given permissions.

func (OsFileSystem) Dir

func (OsFileSystem) Dir(name string) string

Dir returns all but the last element of path, typically the path's directory.

func (OsFileSystem) Exists

func (OsFileSystem) Exists(path string) bool

Exists returns true if the path exists.

func (OsFileSystem) Ext

func (OsFileSystem) Ext(name string) string

Ext returns the file name extension used by path.

func (*OsFileSystem) FindInParent

func (o *OsFileSystem) FindInParent(name string, maxDirCount int) (string, error)

FindInParent searches for a file in the current directory and then in [maxDirCount] parent directories.

func (OsFileSystem) IsAbs

func (OsFileSystem) IsAbs(name string) bool

IsAbs reports whether the path is absolute.

func (OsFileSystem) Join

func (OsFileSystem) Join(elem ...string) string

Join joins any number of path elements into a single path, adding an os-specific separator if necessary.

func (OsFileSystem) Mkdir

func (OsFileSystem) Mkdir(name string, perm os.FileMode) error

MkDir creates a new directory with the specified name and permission bits.

func (OsFileSystem) MkdirAll

func (OsFileSystem) MkdirAll(path string, perm os.FileMode) error

MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error.

func (OsFileSystem) ReadFile

func (OsFileSystem) ReadFile(name string) ([]byte, error)

ReadFile reads the file named by filename and returns the contents.

func (OsFileSystem) RemoveAll

func (OsFileSystem) RemoveAll(name string) error

RemoveAll removes all files and directories in the named directory, including the root.

func (OsFileSystem) Stat

func (OsFileSystem) Stat(name string) (os.FileInfo, error)

Stat returns an os.FileInfo describing the named file or error.

func (OsFileSystem) WalkDir

func (OsFileSystem) WalkDir(name string, walkFn fs.WalkDirFunc) error

WalkDir walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root.

func (OsFileSystem) WriteFile

func (OsFileSystem) WriteFile(filename string, data []byte, perm os.FileMode) error

WriteFile writes data to a file named by filename with [perm].

Jump to

Keyboard shortcuts

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