Skip to content

path

This content is for v0.2.1. Switch to the latest version for up-to-date documentation.

The path namespace ensures cross-platform consistency when working with file system paths on Windows, Linux, and macOS.


FunctionSignatureReturn TypeDescription
path.joinpath.join(...parts)stringCombines path segments using the system separator.
path.basenamepath.basename(p)stringReturns the final portion of a path.
path.dirnamepath.dirname(p)stringReturns the directory name portion of a path.
path.extpath.ext(p)stringExtracts the extension (including leading .).
path.stempath.stem(p)stringReturns the file name without its extension.
path.is_abspath.is_abs(p)boolDetermines if a path is absolute.
path.normalizepath.normalize(p)stringResolves . and .. segments and cleans separators.

Joins multiple path components safely using appropriate platform separators (/ on Linux/macOS, \\ on Windows):

var full = path.join("data", "users", "profile.json");
print(full);

Returns the last element of the path.

print(path.basename("/home/user/project/main.rq"));
print(path.basename("C:\\projects\\app.exe"));

Returns the directory path excluding the final file/folder component.

print(path.dirname("/var/log/nginx/access.log"));

Returns the file extension.

print(path.ext("archive.tar.gz"));
print(path.ext("document.pdf"));
print(path.ext("Makefile"));

Returns the filename without its trailing extension.

print(path.stem("archive.zip"));
print(path.stem("game.exe"));

Checks whether the given path is absolute.

print(path.is_abs("/usr/bin"));
print(path.is_abs("C:\\Windows"));
print(path.is_abs("src/main.rq"));