A pathstd/os/path/path: V
represents a file system path..
Convenience function that adds a string path.
Convenience function that adds two strings into a path.
Convert a path to the absolute path on the file system.
The overload on a plain string is necessary as it allows
for unnormalized paths with ".."
parts. For example
"/foo/symlink/../test.txt"
may resolve to "/bar/test.txt"
if
symlink
is a symbolic link to a sub directory of "/bar"
.
Add two paths together using left-associative operator (/)
.
Keeps the root of p1
and discards the root name of p2
.
"/a/" / "b/foo.txt" (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "/a/b/foo.txt"
"/a/foo.txt" / "/b/bar.txt" (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "/a/foo.txt/b/bar.txt"
"c:/foo" / "d:/bar" (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "c:/foo/bar"
.
Return the first path if it is not empty, otherwise return the second one.
Return the path to the currently executing application.
Return the base directory that contains the currently running application.
First tries app-pathstd/os/path/app-path: () -> io path().nobasestd/os/path/nobase: (p : path) -> path
; if that ends in the bin
or exe
directory it
returns the parent of that directory.
Return the base name of a path (stem name + extension)
"/foo/bar.txt".pathstd/os/path/path: (s : string) -> path.basenamestd/os/path/basename: (p : path) -> string (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "bar.txt"
"/foo".pathstd/os/path/path: (s : string) -> path.basenamestd/os/path/basename: (p : path) -> string (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "foo"
.
Change the base name of a path.
Change the extension of a path. Only adds a dot if the extname does not already start with a dot.
Change the stem name of a path.
Combine multiple paths using (/)
.
Returns the current working directory.
Equal to ".".realpath
.
If a path has no extension, set it to the provided one.
Return the directory part of a path (including the rootname)
"/foo/bar.txt".pathstd/os/path/path: (s : string) -> path.dirnamestd/os/path/dirname: (p : path) -> string (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "/foo"
"/foo".pathstd/os/path/path: (s : string) -> path.dirnamestd/os/path/dirname: (p : path) -> string (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "/"
.
Return a list of all directory components (excluding the root but including the basename).
"/foo/bar/test.txt".pathstd/os/path/path: (s : string) -> path.dirpartsstd/os/path/dirparts: (p : path) -> list<string> (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool ["foo","bar","test.txt"]
.
Return the extension of path (without the preceding dot ('.'
))
"/foo/bar.svg.txt".pathstd/os/path/path: (s : string) -> path.extnamestd/os/path/extname: (p : path) -> string (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "txt"
.
Return the home directory of the current user.
Is a path absolute?
Is a path empty?
Is a path relative?
Remove the basename and only keep the root and directory name portion of the path.
nobasestd/os/path/nobase: (p : path) -> path("foo/bar.ext".pathstd/os/path/path: (s : string) -> path) == "foo")
.
Remove the directory and root and only keep the base name (file name) portion of the path.
nodirstd/os/path/nodir: (p : path) -> path("foo/bar.ext".pathstd/os/path/path: (s : string) -> path) (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "bar.ext"
.
Remove the extension from a path.
Return the last directory component name (or the empty string).
"c:/foo/bar/tst.txt".pathstd/os/path/path: (s : string) -> path.parentnamestd/os/path/parentname: (p : path) -> string (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "bar"
.
Create a normalized pathstd/os/path/path: V
from a path string.
Convert a path to the absolute path on the file system.
The path is not required to exist on disk. However, if it
exists any permissions and symbolic links are resolved fully.
".".realpath
(to get the current working directory)
"/foo".realpath
(to resolve the full root, like "c:/foo"
on windows).
Return the root name of path.
"c:\foo".pathstd/os/path/path: (s : string) -> path.rootnamestd/os/path/rootname: (p : path) -> string (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "c:/"
"/foo".pathstd/os/path/path: (s : string) -> path.rootnamestd/os/path/rootname: (p : path) -> string (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "/"
.
Show a path as a string.
Return the stem name of path.
"/foo/bar.svg.txt".pathstd/os/path/path: (s : string) -> path.extnamestd/os/path/extname: (p : path) -> string (===)std/core/sslice/(===): (slice1 : sslice, slice2 : sslice) -> bool "foo.svg"
.
Convert a pathstd/os/path/path: V
to a normalized stringstd/core/types/string: V
path.
If this results in an empty string, the current directory path "."
is returned.
"c:/foo/test.txt".pathstd/os/path/path: (s : string) -> path.string -> "c:/foo/test.txt"
"c:\foo\test.txt".pathstd/os/path/path: (s : string) -> path.string -> "c:/foo/test.txt"
"/foo//./bar/../test.txt".pathstd/os/path/path: (s : string) -> path.string -> "/foo/test.txt"
.
Return the temporary directory for the current user.
Return the OS specific directory separator ("/"
or "\"
).
Parse a list of paths seperated by colon (':'
) or semi-colon (';'
)
Colon separated paths can be ambiguous with Windows style root names (c:\
)
In particular, a single letter path followed by an absolute path, e.g. c:/foo:/bar
is
parsed as c:/foo
and /bar
.
Return the OS specific path separator (';'
or ':'
).
File system paths.
The path functions are system independent: backward slashes (
'\'
) are treated as a forward slash to separate directories. Windows style root names likec:\
or//server
are also recognized.A list of paths can be separated with either a colon (
:
) or semi-colon (;
).A
pathstd/os/path/path: V
is created using thepathstd/os/path/path: (s : string) -> path
functions. Usestring
to convert back to a normalized path string. A path consists of a root name (/
,c:\
), the directory (foo/bar
) and finally the base name. The base name itself consists of the stem and the extension. The extension is always the part that follows the last occurrence of a dot ('.'
) in the base name.A
pathstd/os/path/path: V
is always normalized. For a sequence of directories, any empty directory or.
directory is ignored. A directory followed by..
is also ignored – this is the Plan 9 interpretation of paths where..
is considered lexically. If parent directories should be resolved through symbolic links, therealpath
function should be used (which has theiostd/core/io: E
effect though).