Documentation ¶
Index ¶
- func CheckMkdir(path string, perm os.FileMode) error
- func Copy(srcFn, dstFn string) error
- func EscapePattern(s string) string
- 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 IsSub(path, sub string) (bool, error)
- func MD5(path string) ([]byte, error)
- func MkdirAll(path string, perm os.FileMode) error
- func PathRelCopy(srcBase, path, dstBase string) (string, error)
- func PathTrunk(p string) string
- func RemoveEmpty(f string) error
- func RenameAll(pattern string, path string) error
- func SplitPath(path string) []string
- func Suffix(f string) string
- 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 EscapePattern ¶
EscapePattern escapes special characters in pattern strings for usage in filepath.Glob() or filepath.Match() See: https://godoc.org/path/filepath#Match
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 IsSub ¶
IsSub returns true if sub is a sub path of path,otherwise false is returned. The function is taken from https://stackoverflow.com/questions/28024731/check-if-given-path-is-a-subdirectory-of-another-in-golang
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 PathRelCopy ¶
PathRelCopy determines first a relative path that is lexically equivalent to path when joined to srcBase with an intervening separator. If this is successful, it returns a path joined from dstBase, a separator and the relative path from the previous step.
func PathTrunk ¶
PathTrunk returns the file path without the file extension. E.g. Trunk("/home/test/abc.mp3") return "/home/test/abc"
func RemoveEmpty ¶
RemoveEmpty removes a file or directory if it is empty. If it is not empty, RemoveEmpty returns and 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