path
This content is for v1.0. 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.
Quick Reference
Section titled “Quick Reference”| Function | Signature | Return Type | Description |
|---|---|---|---|
path.join | path.join(...parts) | string | Combines path segments using the system separator. |
path.basename | path.basename(p) | string | Returns the final portion of a path. |
path.dirname | path.dirname(p) | string | Returns the directory name portion of a path. |
path.ext | path.ext(p) | string | Extracts the extension (including leading .). |
path.stem | path.stem(p) | string | Returns the file name without its extension. |
path.is_abs | path.is_abs(p) | bool | Determines if a path is absolute. |
path.normalize | path.normalize(p) | string | Resolves . and .. segments and cleans separators. |
Detailed Methods
Section titled “Detailed Methods”path.join(...parts)
Section titled “path.join(...parts)”Joins multiple path components safely using appropriate platform separators (/ on Linux/macOS, \\ on Windows):
var full = path.join("data", "users", "profile.json");print(full);path.basename(path)
Section titled “path.basename(path)”Returns the last element of the path.
print(path.basename("/home/user/project/main.rq"));print(path.basename("C:\\projects\\app.exe"));path.dirname(path)
Section titled “path.dirname(path)”Returns the directory path excluding the final file/folder component.
print(path.dirname("/var/log/nginx/access.log"));path.ext(path)
Section titled “path.ext(path)”Returns the file extension.
print(path.ext("archive.tar.gz"));print(path.ext("document.pdf"));print(path.ext("Makefile"));path.stem(path)
Section titled “path.stem(path)”Returns the filename without its trailing extension.
print(path.stem("archive.zip"));print(path.stem("game.exe"));path.is_abs(path)
Section titled “path.is_abs(path)”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"));