Documentation ¶
Index ¶
- func CheckMkdir(path string, perm os.FileMode) error
- func Copy(srcFn, dstFn string) error
- func Exists(path string) (bool, error)
- func Find(roots []Info, filter func(Info, ValidPropagate) (bool, ValidPropagate), ...) (files *[]*Info)
- func GlobOr(patterns []string) (matches []string, err error)
- func IsDir(path string) (bool, error)
- func IsEmpty(path string) (bool, error)
- func MkdirAll(path string, perm os.FileMode) error
- func RemoveEmpty(f string) error
- func RenameAll(pattern string, path string) error
- type Info
- type ValidPropagate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckMkdir ¶
CheckMkdir checks if a directory exists. If it doesn't exist, it's being created
func Copy ¶
Copy copies srcFn to dstFn. Prequisite is, that srcFn and (if existing) dstFn are regular files (i.e. no devices etc.). In case both files are the same, nothing is done. In case, dstFn is already existing it is overwritten.
func Find ¶
func Find(roots []Info, filter func(Info, ValidPropagate) (bool, ValidPropagate), numWorkers int) (files *[]*Info)
Find traverses directory trees to find files that fulfill a certain filter condition. It starts at a list of root directories. The condition must be implemented in a function, which is passed to Find as a parameter. This condition returns two boolean value. The first one determines if a certain entry is valid (i.e. fulfills the actual filter condition), the second determines (only in case of a directory) if the filter result (i.e. the first boolean) shall be propagated to the entries of the directory. numWorkers is the number of concurrent Go routines that Find uses. Find returns the absolute paths of the files and directories that fulfill the filter condition as string array. This function is inspired by the Concurrent Directory Traversal from the book "The Go Programming Language" by Alan A. A. Donovan & Brian W. Kernighan. See: https://github.com/adonovan/gopl.io/blob/master/ch8/du4/main.go
func GlobOr ¶
GlobOr execute filepath.Glob on a list of patterns. The result is a list of files that match at least one of the patterns in the list. GlobOr returns an error if at least one of the calls of filepath.Glob returned an error
func MkdirAll ¶
MkdirAll creates a directory named path, along with any necessary parents. In this regard, it behaves like the standard os.MkdirAll. In contrast to this, it doesn't complain if path already exists.
func RemoveEmpty ¶
RemoveEmpty removes a file or directory if it is empty. If it is not empty, RemoveEmpty returns an error
Types ¶
type Info ¶
Info extends the standard interface os.FileInfo
func ExistsInfo ¶
ExistsInfo returns true if path exists, otherwise false. In addition to Exists it also return file.Info
type ValidPropagate ¶
type ValidPropagate int
ValidPropagate defines if validity shall be propagated to sub directories. Needed for Find()
const ( NoneFromSuper ValidPropagate = iota // no propagation to sub directories ValidFromSuper // propagate valid=true to sub directories InvalidFromSuper // propagate valid=false to sub directories )
constants for Find(): propagation of validity to sub directories