Documentation ¶
Overview ¶
Package pfs provides file-system related functions
Index ¶
- Constants
- Variables
- func Abs(dir string) (out string)
- func AbsEval(path string) (p string, err error)
- func Dirs(dir string, callback ...func(dir string) (err error)) (dirs []string, err error)
- func Elems(path string) (dirs []string, file string)
- func EnsureDirectory(directory string, dirMode fs.FileMode)
- func Exists(path string) (fileInfo fs.FileInfo)
- func GetModeBitValues() (s string)
- func IsDirectory(path string, flags IsDirectoryArg) (isDirectory bool, err error)
- func IsEmptyDirectory(path string, ignoreENOENT ...bool) (isEmpty bool)
- func MoveOrMerge(src, dest string, outConsumer func(string)) (err error)
- func Mv(src, dest string, outConsumer func(string)) (err error)
- func NewContextReader(ctx context.Context, reader io.Reader) io.Reader
- func Stat(path string) (fileInfo fs.FileInfo, err error)
- func TestElemsX(t *testing.T)
- func Walk(root string, walkFn filepath.WalkFunc) (err error)
- type ContextReader
- type DLEntry
- type Directory
- type DirectoryLister
- type Entry
- type EntryResult
- type FSEntry
- type FileMode
- type IsDirectoryArg
- type Root
- type Sha256
- type Tree
Constants ¶
const ( // AllModeBits is all known github.com/fsnotify/fsevents.EventFlags AllModeBits fs.FileMode = fs.ModeDir | fs.ModeAppend | fs.ModeExclusive | fs.ModeTemporary | fs.ModeSymlink | fs.ModeDevice | fs.ModeNamedPipe | fs.ModeSocket | fs.ModeSetuid | fs.ModeSetgid | fs.ModeCharDevice | fs.ModeSticky | fs.ModeIrregular )
Variables ¶
var EndListing = errors.New("endListing")
Functions ¶
func Abs ¶ added in v0.4.23
Abs ensures a file system path is fully qualified. Abs is single-return-value and panics on troubles
func Dirs ¶
Dirs retrieves absolute paths to all directories, while following symlinks, from initial dir argument. callback: cb is 6–58% faster than slice, results are found faster, and it can be canceled midway. if callback blocks, not good…
func Elems ¶ added in v0.4.26
Elems splits a path into a list of directory names and base filename part. if path is absolute, dirs[0] is "/". if there is no separator in path, dirs is empty. if path is empty string, dirs is empty and file is empty string.
func EnsureDirectory ¶
use 0 for default file mode owner rwx
func Exists ¶
Exists determines if a path exists If the path exists, fileInfo is non-nil if the path does not exist, fileInfo is nil panic on troubles
func GetModeBitValues ¶
func GetModeBitValues() (s string)
func IsDirectory ¶
func IsDirectory(path string, flags IsDirectoryArg) (isDirectory bool, err error)
func IsEmptyDirectory ¶
IsEmptyDirectory checks if a directory is empty. ignoreENOENT if true, a non-exiting directory is ignored. pamnic on troubles
func MoveOrMerge ¶
func Mv ¶
Mv moves a file or directory structure using system command. Mv uses -n for --n-clobber. Mv does not indicate if moive was aborted due to no-clobber. outConsumer can be nil but receiver command output if any. mv typically has no output.
func NewContextReader ¶
NewContextReader instantiates ContextReader
func TestElemsX ¶ added in v0.4.26
Types ¶
type ContextReader ¶
ContextReader reader terminated by context
type DLEntry ¶
type DirectoryLister ¶
type DirectoryLister struct { Path string // may begin with ., may be . Abs string Results chan *EntryResult // contains filtered or unexported fields }
func NewDirStream ¶
func NewDirStream(path string, chanSize int) (dir *DirectoryLister)
func (*DirectoryLister) Shutdown ¶
func (dir *DirectoryLister) Shutdown()
type Entry ¶
type Entry struct { Base string // we can have entries with FileInfo nil, so base path must be stored os.FileInfo // info.Name() has basename, os.FileInfo: interface Err error // a symlink may fail to resolve }
Entry is a file system entry that can be part of directory, symlink or other
type EntryResult ¶
func GetErrorResult ¶
func GetErrorResult(err error) (result *EntryResult)
type FSEntry ¶
type FSEntry interface { SafeName() string IsDir() bool Walk(path string, walkFunc filepath.WalkFunc) error }
FSEntry represnt a branch in a file system hierarchy FSEntry is implemented by Entry (file) or Directory or Root (walk entry point)
func NewDirectory ¶
NewDirectory instantiates FSEntry that can have children
type FileMode ¶
type IsDirectoryArg ¶
type IsDirectoryArg byte
const ( IsDirectoryNonExistentIsError IsDirectoryArg = 1 << iota IsDirectoryNotDirIsError )
type Root ¶
type Root struct { Path string // path as provided Evaled string // path after filepath.EvalSymlinks Err error FSEntry // Directory or Entry }
Root is a file system hierarchy
type Sha256 ¶
type Sha256 []byte
Sha256 contains sha-256 hash
func Sha256Context ¶
Sha256Context get sha256 of a file with context