Janet 1.39.1-e9c6678 Documentation
(Other Versions:
1.38.0
1.37.1
1.36.0
1.35.0
1.34.0
1.31.0
1.29.1
1.28.0
1.27.0
1.26.0
1.25.1
1.24.0
1.23.0
1.22.0
1.21.0
1.20.0
1.19.0
1.18.1
1.17.1
1.16.1
1.15.0
1.13.1
1.12.2
1.11.1
1.10.1
1.9.1
1.8.1
1.7.0
1.6.0
1.5.1
1.5.0
1.4.0
1.3.1
)
path
Simple path manipulation module for Janet. Supports manipulation both windows and posix paths on any platform, and provides functions that work according to the current host platform.
All functions have three forms, under path
, path/win
, and
path/posix
. The prefix indicates which type of path the function
manipulates.
Example
(import spork/path)
# Examples for a non-windows system, use path/win/ for windows and
# path/posix/ for posix.
(path/ext "my/long/path.txt") # -> ".txt"
path/sep # -> "/" on posix, "\\" on windows
path/delim # -> ":" on posix, ";" on windows
(path/basename "some/path.txt") # -> "path.txt"
(path/dirname "some/path.txt") # -> "some/"
(path/parts "some/path/file.txt") # -> ["some" "path" "file.txt"]
(path/normalize "some/.././thing/file.txt") # -> "thing/file.txt"
(path/join "some/path" "../thing/file.txt") # -> "some/thing/file.txt"
(path/abspath? "/home/blah") # -> true
(path/abspath "file.txt") # -> "/home/me/cwd/file.txt"
(path/relpath
"a/nested/directory/with/a/few/children"
"a/nested/directory/with/different/children") # -> "../../../different/children"
Reference
path/abspath path/abspath? path/basename path/delim path/dirname path/ext path/join path/normalize path/parts path/posix/abspath path/posix/abspath? path/posix/basename path/posix/delim path/posix/dirname path/posix/ext path/posix/join path/posix/normalize path/posix/parts path/posix/relpath path/posix/sep path/relpath path/sep path/win32/abspath path/win32/abspath? path/win32/basename path/win32/delim path/win32/dirname path/win32/ext path/win32/join path/win32/normalize path/win32/parts path/win32/relpath path/win32/sep
(posix/normalize path) Normalize a path. This removes . and .. in the path, as well as empty path elements.
(posix/normalize path) Normalize a path. This removes . and .. in the path, as well as empty path elements.
(posix/relpath source target) Get the relative path between two subpaths.
(posix/relpath source target) Get the relative path between two subpaths.
(win32/normalize path) Normalize a path. This removes . and .. in the path, as well as empty path elements.
(win32/relpath source target) Get the relative path between two subpaths.