-
Notifications
You must be signed in to change notification settings - Fork 4
The path library
The path library supplies utility routines for manipulating slash-separated paths.
base returns the last element of path. Trailing slashes are removed before extracting the last element. If the path is empty, base returns ".". If the path consists entirely of slashes, base returns "/".
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:
- Replace multiple slashes with a single slash.
- Eliminate each . path name element (the current directory).
- Eliminate each inner .. path name element (the parent directory) along with the non-.. element that precedes it.
- Eliminate .. elements that begin a rooted path: that is, replace "/.." by "/" at the beginning of a path.
The returned path ends in a slash only if it is the root "/". If the result of this process is an empty string,
cleanreturns the string "."
dir returns all but the last element of path, typically the path's directory. After dropping the final element using split, the path is cleaned and trailing slashes are removed. If the path is empty, dir returns ".". If the path consists entirely of slashes followed by non-slash bytes, Dir returns a single slash. In any other case, the returned path does not end in a slash.
Returns the file name extension used by path. The extension is the suffix beginning at the final dot in the final slash-separated element of path; it is empty if there is no dot.
Tests whether the path is absolute.
join joins any number of path elements into a single path, separating them with slashes. 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.
Tests whether the given name matches the pattern, where the patters is specified according to the usual shell matching patterns, e.g. * is a wildcard.
split splits path immediately following the final slash, separating it into a directory and filename component. If there is no slash in path, Split returns "" as the directory and the filename the same as path. The returned values have the property that if we set dir, filename = split(path), then path == dir+filename.
This page is automatically generated from the Pipefish standard library. Any edits made directly to this wiki page will be overwritten the next time the documentation is regenerated.
🧿 Pipefish is distributed under the MIT license. Please steal my code and ideas.
- Getting started
- Language basics
- The type system and built-in functions
- Functional Pipefish
- Encapsulation
- Imperative Pipefish
-
Imports and libraries
- The crypto/aes library
- The crypto/bcrypt library
- The crypto/rand library
- The crypto/rsa library
- The crypto/sha_256 library
- The crypto/sha_512 library
- The database/sql library
- The encoding/base_32 library
- The encoding/base_64 library
- The encoding/csv library
- The encoding/json library
- The files library
- The fmt library
- The html library
- The image library
- The image/bmp library
- The image/color library
- The image/jpeg library
- The image/png library
- The lists library
- The markdown library
- The math library
- The math/big library
- The math/cmplx library
- The math/rand library
- The net/http library
- The net/mail library
- The net/smtp library
- The net/url library
- The os/exec library
- The path library
- The path/filepath library
- The reflect library
- The regexp library
- The strconv library
- The strings library
- The terminal library
- The time library
- The unicode library
- Advanced Pipefish
- Developing in Pipefish
- Deployment
- Appendices