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


path/abspath function source
(posix/abspath path)

Coerce a path to be absolute.

path/abspath? function source
(posix/abspath? path)

Check if a path is absolute.

path/basename function source
(posix/basename path)

Gets the base file name of a path.

path/delim string source
Platform delimiter

path/dirname function source
(posix/dirname path)

Gets the directory name of a path.

path/ext function source
(ext path)

Get the file extension for a path.

path/join function source
(posix/join & els)

Join path elements together.

path/normalize function source
(posix/normalize path)

Normalize a path. This removes . and .. in the path, as well as empty path elements.

path/parts function source
(posix/parts path)

Split a path into its parts.

path/posix/abspath function source
(posix/abspath path)

Coerce a path to be absolute.

path/posix/abspath? function source
(posix/abspath? path)

Check if a path is absolute.

path/posix/basename function source
(posix/basename path)

Gets the base file name of a path.

path/posix/delim string source
Platform delimiter

path/posix/dirname function source
(posix/dirname path)

Gets the directory name of a path.

path/posix/ext function source
(ext path)

Get the file extension for a path.

path/posix/join function source
(posix/join & els)

Join path elements together.

path/posix/normalize function source
(posix/normalize path)

Normalize a path. This removes . and .. in the path, as well as empty path elements.

path/posix/parts function source
(posix/parts path)

Split a path into its parts.

path/posix/relpath function source
(posix/relpath source target)

Get the relative path between two subpaths.

path/posix/sep string source
Platform separator

path/relpath function source
(posix/relpath source target)

Get the relative path between two subpaths.

path/sep string source
Platform separator

path/win32/abspath function source
(win32/abspath path)

Coerce a path to be absolute.

path/win32/abspath? function source
(win32/abspath? path)

Check if a path is absolute.

path/win32/basename function source
(win32/basename path)

Gets the base file name of a path.

path/win32/delim string source
Platform delimiter

path/win32/dirname function source
(win32/dirname path)

Gets the directory name of a path.

path/win32/ext function source
(ext path)

Get the file extension for a path.

path/win32/join function source
(win32/join & els)

Join path elements together.

path/win32/normalize function source
(win32/normalize path)

Normalize a path. This removes . and .. in the path, as well as empty path elements.

path/win32/parts function source
(win32/parts path)

Split a path into its parts.

path/win32/relpath function source
(win32/relpath source target)

Get the relative path between two subpaths.

path/win32/sep string source
Platform separator