Documentation
¶
Index ¶
- Variables
- func CleanKeepDotDot(p string) string
- func DirKeepDotDot(p string) string
- func ExpandEnv(s string) string
- func ExpandUser(p string) string
- func ExpandUserKeepDotDot(p string) (string, error)
- func ExpandUserPath(p string) (string, error)
- func FileURL(p string) (string, error)
- func FoldCase(p string) string
- func FromFileURL(rawURL string) (string, error)
- func Glob(root, pattern string) ([]string, error)
- func Home() (string, error)
- func IsMissing(err error) bool
- func Join(base string, elem ...string) string
- func JoinKeepDotDot(base string, elem ...string) string
- func Name(p string) string
- func NameKeepDotDot(p string) string
- func Parents(p string) []string
- func Parts(p string) (anchor string, elems []string)
- func RelativeTo(p, root string) (string, bool)
- func RelativeToKeepDotDot(p, root string) (string, bool)
- func Resolve(p string) (string, error)
- func ResolveExisting(p string) (string, error)
- func ResolveLink(dir, target string) (string, error)
- func SlashRel(base, target string) (string, error)
- func SplitExt(p string) (root, ext string)
- func StatIfExists(p string) (fs.FileInfo, error)
- func Stem(p string) string
- func Suffix(p string) string
- func TempDir() (string, error)
- func TempDirCandidates() []string
- func WindowsBase(p string) string
- func WindowsClean(p string) string
- func WindowsDir(p string) string
- func WindowsFoldCase(p string) string
- func WindowsIsAbs(p string) bool
- func WindowsJoin(base string, elem ...string) string
- func WindowsSplitDrive(p string) (drive, rest string)
- func WindowsSplitRoot(p string) (drive, root, rest string)
- func WithSuffix(p, suffix string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoHome = errors.New("home directory cannot be determined")
Error of a home directory lookup that found nothing
Functions ¶
func CleanKeepDotDot ¶
Path with repeated separators and dot elements dropped and every dot-dot kept, so it still names the file the system opens when a dot-dot climbs out of a symlinked directory; a dot when nothing is left
func DirKeepDotDot ¶
CleanKeepDotDot form of p without its final element, a dot-dot one included, so it is the directory the system walks through to reach that element; the bare anchor or a dot when p has no element
func ExpandEnv ¶
Text with $name and ${name} references, and on Windows also %name%, $$, %% and literal 'quoted' spans, replaced from the environment, references to unset variables left as written
func ExpandUser ¶
Path with a leading ~ or ~name replaced by that user's home directory, unchanged when that home cannot be found
func ExpandUserKeepDotDot ¶
CleanKeepDotDot form of p with a leading ~ or ~name replaced by that user's home directory, so a dot-dot after a symlink still names what the system opens; an error wrapping ErrNoHome when that home cannot be found
func ExpandUserPath ¶
Cleaned path with a leading ~ or ~name replaced by that user's home directory, an error wrapping ErrNoHome when that home cannot be found
func FileURL ¶
File URL of an absolute path with every byte but unreserved characters and separators percent-encoded, file:///C:/x for a Windows drive and file://host/share/x for a share, the \\?\ long-path forms of both included
func FoldCase ¶
Comparison key of a path for a host whose file names ignore case: lower case with backslash separators on Windows, the path itself elsewhere
func FromFileURL ¶
Native path a file URL names, failing for another scheme, an encoded separator, or another host except on Windows where a host names a share
func Glob ¶
Paths below root matching a relative pattern of shell wildcard elements, ** standing for any depth of directories without entering symlinked ones and a trailing separator for directories only, in directory order
func Home ¶
Cleaned home directory of the current user, from the environment and else from the account database
func IsMissing ¶
Whether err says a path is not there: not found, below a non-directory, behind a symlink loop or not a valid name
func Join ¶
Elements joined like filepath.Join, except that an absolute element replaces everything before it
func JoinKeepDotDot ¶
Elements joined as Join joins them, an absolute element replacing everything before it, with the result in CleanKeepDotDot form instead of cleaned; empty when every element is empty
func NameKeepDotDot ¶
Final element of the CleanKeepDotDot form of p, a dot-dot one included, empty for a bare anchor or a path with no element
func Parents ¶
Ancestors of the cleaned path from its parent up to its root, or up to a dot for a relative path
func Parts ¶
Anchor of a path, its volume and root separator, and its elements with empty and dot elements dropped and dot-dot kept
func RelativeTo ¶
Path of p below root with slash separators, a dot for root itself, false unless p is root or inside it once both are cleaned; case is ignored on Windows
func RelativeToKeepDotDot ¶
Elements of p after those of root joined with slashes, both taken in CleanKeepDotDot form so a dot-dot is matched as an element and the result names the same file below root; a dot for root itself, false unless the anchor and elements of root begin p; case is ignored on Windows
func Resolve ¶
Absolute path with every symlink resolved as far as the path exists, the missing tail and any symlink loop kept as written
func ResolveExisting ¶
Absolute path with every symlink resolved, failing when any part of it is missing, not a directory where one is needed or a symlink loop
func ResolveLink ¶
Where a symlink in dir holding the text target leads, resolved as Resolve resolves a path, a relative target walked from dir the way the system follows it instead of being cleaned against dir first
func SlashRel ¶
Slash separated path that leads from base to target lexically on any host, failing when only one of them is absolute or base climbs out of reach
func SplitExt ¶
Path as written split before the extension of its final element, the extension found the way Suffix finds it
func StatIfExists ¶
Followed stat of p, a nil info and nil error when IsMissing reads its failure as a missing path or p holds a NUL byte
func Suffix ¶
Extension of the final element from its last dot, empty when that dot is one of the leading dots of a name such as .bashrc
func TempDir ¶
First of the TempDirCandidates in which this process can create, write and remove a file, made absolute
func TempDirCandidates ¶
func TempDirCandidates() []string
Directories a temporary directory is chosen from, in order: TMPDIR, TEMP and TMP when set, the platform's usual places, then the working directory
func WindowsBase ¶
Final element of a Windows path on any host after trailing separators, a dot for an empty path and a backslash for a bare anchor, the way filepath.Base treats Windows paths
func WindowsClean ¶
Windows path cleaned on any host: backslash separators, empty and dot elements dropped, dot-dot folded below the anchor, a dot for nothing
func WindowsDir ¶
Windows path without its final element on any host, cleaned, a dot when no directory is left and the share itself for a share root, the way filepath.Dir treats Windows paths
func WindowsFoldCase ¶
Comparison key of a Windows path on any host, lower case with backslash separators
func WindowsIsAbs ¶
Whether a Windows path is absolute on any host: a drive letter followed by a separator, or a leading double separator
func WindowsJoin ¶
Elements joined and cleaned under Windows rules on any host: a rooted element restarts the path on the current drive, another drive restarts it, empty for nothing but empty elements
func WindowsSplitDrive ¶
Drive letter or UNC share of a Windows path on any host and everything after it
func WindowsSplitRoot ¶
Drive letter or UNC share, root separator and the rest of a Windows path on any host, the three concatenating back to p
func WithSuffix ¶
Cleaned path with the Suffix of its final element replaced by suffix, which is empty or starts with a dot and holds no separator, so that any Suffix result fits
Types ¶
This section is empty.