Documentation
¶
Overview ¶
Package fsutil provides filesystem utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClaimFileBadPattern = errors.New("ClaimFile: pattern must contain exactly one asterisk")
ErrClaimFileBadPattern is thrown when the pattern argument passed to ClaimFile does not contain exactly one asterisk.
Functions ¶
func ClaimFile ¶
ClaimFile takes a directory and a pattern string containing exactly one asterisk (e.g. "a*.log"). It opens a file in that directory, with a filename matching the template, with "*" replaced by a number. That number is one plus the largest of all existing files matching the template. If no such file exists, "*" is replaced by 1. The file is opened for read and write, with permission 0666 (before umask).
For example, if the directory /tmp/elvish contains a1.log, a2.log and a9.log, calling ClaimFile("/tmp/elvish", "a*.log") will open a10.log. If the directory has no files matching the pattern, this same call will open a1.log.
This function is useful for automatically determining unique names for log files. Unique filenames can also be derived by embedding the PID, but using this function preserves the chronical order of the files.
This function is concurrency-safe: it always opens a new, unclaimed file and is not subject to race condition.
func DontSearch ¶
DontSearch determines whether the path to an external command should be taken literally and not searched.
func EachExternal ¶
func EachExternal(f func(string))
EachExternal calls f for each executable file found while scanning the directories of $E:PATH.
NOTE: EachExternal may generate the same command multiple times; once for each time it appears in $E:PATH. That is, no deduplication of the files found by scanning $E:PATH is performed.
func GetHome ¶
GetHome finds the home directory of a specified user. When given an empty string, it finds the home directory of the current user.
func Getwd ¶
func Getwd() string
Getwd returns path of the working directory in a format suitable as the prompt.
func IsExecutable ¶
IsExecutable returns whether the FileInfo refers to an executable file.
This is determined by permission bits on Unix, and by file name on Windows.
Types ¶
This section is empty.