Documentation
¶
Index ¶
- func BinDirectory(filename string) bool
- func CanRead(filename string) bool
- func ClearCache()
- func DataReadyOnStdin() bool
- func DirectoryWithFiles(path string) (bool, error)
- func Exists(path string) bool
- func ExistsCached(path string) bool
- func FileHas(path, what string) bool
- func FilterOutBinaryFiles(filenames []string) []string
- func IsBinary(filename string) bool
- func IsDir(path string) bool
- func IsExecutable(path string) bool
- func IsExecutableCached(path string) bool
- func IsFile(path string) bool
- func IsFileOrSymlink(path string) bool
- func IsSymlink(path string) bool
- func PathHas(executable string) bool
- func PathHasCached(executable string) bool
- func ReadString(filename string) string
- func Relative(path string) string
- func RemoveFile(path string) error
- func ShortPath(path string) string
- func TimestampedFilename(filename string) string
- func Touch(filename string) error
- func Which(executable string) string
- func WhichCached(executable string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinDirectory ¶
BinDirectory will check if the given filename is in one of these directories: /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin, ~/.bin, ~/bin, ~/.local/bin
func CanRead ¶ added in v1.1.0
CanRead checks if 1 byte can actually be read from the given filename
func DataReadyOnStdin ¶
func DataReadyOnStdin() bool
DataReadyOnStdin checks if data is ready on stdin
func DirectoryWithFiles ¶ added in v1.8.0
DirectoryWithFiles checks if the given path is a directory and contains at least one file
func ExistsCached ¶ added in v1.5.0
ExistsCached checks if the given path exists, using a cache for faster access. Assumes that the filesystem has not changed since the last check.
func FilterOutBinaryFiles ¶
FilterOutBinaryFiles filters out files that are either binary or can not be read
func IsBinary ¶ added in v1.4.0
IsBinary returns true if the given filename can be read and is a binary file
func IsExecutable ¶ added in v1.9.0
IsExecutable checks if the given path exists and is executable
func IsExecutableCached ¶ added in v1.9.0
IsExecutableCached checks if the given path exists and is an executable file, with cache support. Assumes that the filesystem permissions have not changed since the last check.
func IsFileOrSymlink ¶
IsFileOrSymlink checks if the given path exists and is a regular file or a symbolic link
func PathHasCached ¶ added in v1.7.0
PathHasCached checks if the given executable is in $PATH (looks in the cache first and then caches the result)
func ReadString ¶ added in v1.1.0
ReadString returns the contents of the given filename as a string. Returns an empty string if there were errors.
func Relative ¶ added in v1.4.2
Relative takes an absolute or relative path and attempts to return it relative to the current directory. If there are errors, it simply returns the given path.
func RemoveFile ¶ added in v1.5.0
RemoveFile deletes a file, but it only returns an error if the file both exists and also could not be removed
func ShortPath ¶
ShortPath replaces the home directory with ~ in a given path. The given path is expected to contain the home directory path either 0 or 1 times, and if it contains the path to the home directory, it is expected to be at the start of the given string.
func TimestampedFilename ¶
TimestampedFilename prefixes the given filename with a timestamp
func Touch ¶ added in v1.5.0
Touch behaves like "touch" on the command line, and creates a file or updates the timestamp
func Which ¶
Which tries to find the given executable name in the $PATH Returns an empty string if not found.
func WhichCached ¶ added in v1.6.0
WhichCached tries to find the given executable name in the $PATH, using a cache for faster access. Assumes that the $PATH environment variable has not changed since the last check.
Types ¶
This section is empty.