System Module

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.

Native Normalization
XHSC handles path resolution natively. It aggressively resolves .. 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.

typescript
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.

typescript
const logPath = __sys__.path.join("var", "logs", "app.log");
.dirname(p)

Parent folder path.

.basename(p, ext?)

Filename with optional ext stripping.

.extname(p)

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.

typescript
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.

typescript
const fixed = __sys__.path.correct("/tmp/app/tmp/app/user", { verify: true });
.normalize(p)

Collapses separators and resolves dots.

.relative(from, to)

Calculates relative trajectory between paths.

.isChild(parent, child)

Verifies strict containment boundaries.

Path Status Checkers

.exists(p)
Check if path exists.
.isDir(p)
Verify directory type.
.isFile(p)
Verify file type.
.isSymlink(p)
Verify symbolic link.
.isEmpty(p)
Check if empty (0 bytes/entries).
.isAbsolute(p)
Check for absolute path.
.metadata(p)
High-speed anatomy snapshot.
.tempDir()
Get OS temp directory.

Advanced Utilities

.commonBase(...paths)

Finds the deepest shared parent directory across a set of paths.

typescript
__sys__.path.commonBase("/src/models/a.ts", "/src/routes/b.ts"); // -> "/src"
.toNamespacedPath(p)

Handles UNC and long paths on Windows.

.normalizeSeparators(p)

Standardizes separators to OS-native format.

Operating System

Monitor hardware telemetry, processes, and network sockets natively.