Documentation ¶
Overview ¶
Package fs contains helper functions to deal with files and folders.
Index ¶
- func AbsoluteFileExists(path string) (res bool)
- func ApplyCommands(cmds []*exec.Cmd, title string, verbose bool) error
- func CalculateMD5First4KB(path string) string
- func CalculateSHA256(filename string) (string, error)
- func CopyDir(src, dst string, useHardLinks bool) error
- func CopyFile(src, dst string, useHardLinks bool) (err error)
- func DeleteEmptyDirs(root string) error
- func DirExists(path string) bool
- func DirIsEmpty(path string) (bool, error)
- func DownloadFile(filepath string, url string) error
- func FileExists(path string) bool
- func FileSize(a uint64) string
- func FileSizeDelta(a int64) string
- func GetFilesByExt(directoryPath, extension string) ([]string, error)
- func GetMaxPathLength(dir string) int
- func GetUniqueTimestampedFilename(dir, filename, extension string) (string, error)
- func MoveDir(current, new string, doNothing, interactive bool) (bool, error)
- func SanitizePath(path string) string
- func Sign(a int64) string
- type ByteSize
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbsoluteFileExists ¶
AbsoluteFileExists checks if an absolute path is an existing fs.
func ApplyCommands ¶ added in v0.16.0
ApplyCommands using goroutines. Can be applied to files.
func CalculateMD5First4KB ¶
CalculateMD5First4KB calculates the MD5 of the beginning of a fs.
func CalculateSHA256 ¶
CalculateSHA256 calculates a fs's current hash
func CopyDir ¶
CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.
func CopyFile ¶
CopyFile copies a fs from src to dst. If src and dst files exist, and are the same, then return success. Copy the fs contents from src to dst.
func DeleteEmptyDirs ¶
DeleteEmptyDirs recursively deletes empty folders in a given path.
func DirIsEmpty ¶
DirIsEmpty checks if a directory is empty.
func DownloadFile ¶
DownloadFile will download a url to a local file. It will write as it downloads and not load the whole file into memory.
func FileSizeDelta ¶
func GetFilesByExt ¶ added in v0.3.0
GetFilesByExt returns all files found in a directory with a specific extension
func GetMaxPathLength ¶ added in v0.17.0
GetMaxPathLength inside a directory, including the name of the directory itself.
func GetUniqueTimestampedFilename ¶
GetUniqueTimestampedFilename for a given filename.