cwdstringisWindowsboolpathSeparatorbyte
Abs returns an absolute representation of path.
If the path is not absolute it will be joined with the current
working directory to turn it into an absolute path. The absolute
path name for a given file is not guaranteed to be unique.
Abs calls Clean on the result.
Base returns the last element of path.
Trailing path separators are removed before extracting the last element.
If the path is empty, Base returns ".".
If the path consists entirely of separators, Base returns a single separator.
Clean returns the shortest path name equivalent to path
by purely lexical processing. It applies the following rules
iteratively until no further processing can be done:
1. Replace multiple Separator elements with a single one.
2. Eliminate each . path name element (the current directory).
3. Eliminate each inner .. path name element (the parent directory)
along with the non-.. element that precedes it.
4. Eliminate .. elements that begin a rooted path:
that is, replace "/.." by "/" at the beginning of a path,
assuming Separator is '/'.
The returned path ends in a slash only if it represents a root directory,
such as "/" on Unix or `C:\` on Windows.
Finally, any occurrences of slash are replaced by Separator.
If the result of this process is an empty string, Clean
returns the string ".".
See also Rob Pike, ``Lexical File Names in Plan 9 or
Getting Dot-Dot Right,''
https://9p.io/sys/doc/lexnames.html
Dir returns all but the last element of path, typically the path's directory.
After dropping the final element, Dir calls Clean on the path and trailing
slashes are removed.
If the path is empty, Dir returns ".".
If the path consists entirely of separators, Dir returns a single separator.
The returned path does not end in a separator unless it is the root directory.
EvalSymlinks returns the path name after the evaluation of any symbolic
links.
If path is relative the result will be relative to the current directory,
unless one of the components is an absolute symbolic link.
EvalSymlinks calls Clean on the result.
Ext returns the file name extension used by path.
The extension is the suffix beginning at the final dot
in the final element of path; it is empty if there is
no dot.
FromSlash returns the result of replacing each slash ('/') character
in path with a separator character. Multiple slashes are replaced
by multiple separators.
IsAbs reports whether the path is absolute.
IsPathSeparator reports whether c is a directory separator character.
isUNC reports whether path is a UNC path.
Join joins any number of path elements into a single path,
separating them with an OS specific Separator. Empty elements
are ignored. The result is Cleaned. However, if the argument
list is empty or all its elements are empty, Join returns
an empty string.
On Windows, the result will only be a UNC path if the first
non-empty element is a UNC path.
joinNonEmpty is like join, but it assumes that the first element is non-empty.
Rel returns a relative path that is lexically equivalent to targpath when
joined to basepath with an intervening separator. That is,
Join(basepath, Rel(basepath, targpath)) is equivalent to targpath itself.
On success, the returned path will always be relative to basepath,
even if basepath and targpath share no elements.
An error is returned if targpath can't be made relative to basepath or if
knowing the current working directory would be necessary to compute it.
Rel calls Clean on the result.
( T) sameWord(a, b string) bool
VolumeName returns leading volume name.
Given "C:\foo\bar" it returns "C:" on Windows.
Given "\\host\share\foo" it returns "\\host\share".
On other platforms it returns "".
volumeNameLen returns length of the leading volume name on Windows.
It returns 0 elsewhere.
A lazybuf is a lazily constructed path buffer.
It supports append, reading previously appended bytes,
and retrieving the final string. It does not allocate a buffer
to hold the output until that output diverges from s.
buf[]bytepathstringvolAndPathstringvolLenintwint(*T) append(c byte)(*T) index(i int) byte(*T) string() string
Some file systems have a time resolution of only a few seconds. If a mtime
value is too new, we won't be able to tell if it has been recently modified
or not. So we only use mtimes for comparison if they are sufficiently old.
Apparently the FAT file system has a resolution of two seconds according to
this article: https://en.wikipedia.org/wiki/Stat_(system_call).
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.