Filesystem Module

Helpers & Utils

High-level convenience methods designed to simplify complex I/O patterns. These utilities supplement the core API with practical tools for JSON handling, binary data manipulation, and automated directory management.

Filtered & Recursive Listing

.lsRecursive(path, filter?)

Deep traversal with optional callback filtering.

typescript
const tsFiles = __sys__.fs.lsRecursive("ROOT://src", f => f.endsWith(".ts"));
.lsDirs(p)Returns only subdirectory names.
.lsFiles(p)Returns only file names.
.lsFullPath(p)Returns fully resolved absolute paths.

JSON Automation

Native JSON serialization using XStringify with safe fallback options.

.readJsonSafe(path, default)

Returns default instead of throwing if the file is missing or malformed.

.readJson(path)
.writeJson(path, data)

Binary & Raw I/O

.readBytes() / .writeBytes()

Bypass text encoding entirely. Works with raw Node Buffer objects.

.readLines() / .readNonEmptyLines()

Synchronous or asynchronous line-by-line reading.

Native Stats & Utilities

.hash(p)

Natively compute checksum.

.size(p)

Bytes or human-readable size.

.du(p)

Full directory tree usage.

.sync(s, d)

One-way directory mirror.

.ensureDir(path)

Never-throw directory creation.

.writeIfNotExists(path, data)

Conditional write operation.

.dedupe(path)

Identify duplicates via hash.

.check(path)

Verify existence and status.

Search & Patterns

Master full-text search and glob discovery across your project structure.