Path Manipulation (path)
Robust, platform-independent path utilities with integrated security boundaries.
The path module provides a comprehensive suite of utilities for working with file and directory paths. By bridging operations directly to the native XHSC engine, it eliminates cross-platform separator issues and provides extreme security against directory traversal attacks.
.. and . references, ensuring rigorous adherence to filesystem capabilities across Windows, macOS, and Linux.Core Assembly & Slicing
.resolve(...paths)
Resolves a sequence of segments into an absolute path, natively resolving all parent (..) references.
const configPath = __sys__.path.resolve("config", "settings.json");
// Output (Linux): "/home/user/project/config/settings.json".join(...paths)
Safely joins segments using platform-specific separators and normalizes the result.
const logPath = __sys__.path.join("var", "logs", "app.log");Parent folder path.
Filename with optional ext stripping.
File extension (including dot).
Operations & Security Enforcement
.secureJoin(base, ...segments)
Enterprise defense against traversal attacks. Rejects or clamps segments if they attempt to escape the base directory.
const safe = __sys__.path.secureJoin("/var/www/uploads", "../../etc/passwd");
// Native Go Core rejects the traversal instantly!.correct(path, options?)
Eliminates structural redundancies (e.g., prefix doubling). verify: true ensures each step yields an existing path.
const fixed = __sys__.path.correct("/tmp/app/tmp/app/user", { verify: true });Collapses separators and resolves dots.
Calculates relative trajectory between paths.
Verifies strict containment boundaries.
Path Status Checkers
Advanced Utilities
.commonBase(...paths)
Finds the deepest shared parent directory across a set of paths.
__sys__.path.commonBase("/src/models/a.ts", "/src/routes/b.ts"); // -> "/src"Handles UNC and long paths on Windows.
Standardizes separators to OS-native format.
Monitor hardware telemetry, processes, and network sockets natively.
