fs.* & reg.* — Transactional Filesystem & Stateless 64/32-Bit Registry
fs.* and reg.* are gated to use installer; (and use showcase; in Community/Architect editions; blocked in sandboxed profiles via RSW702). Every mutating call is 100% rollback-journaled inside install { ... } and rejected inside wizard { ... } by RSW701.
fs.* — Read-Only Inspection & Cryptographic Verification (19 Methods)
| Method | Signature | Return | Description |
|---|---|---|---|
fs.exists | fs.exists(target: path) | bool | Returns true if file or directory exists. |
fs.isDir | fs.isDir(target: path) | bool | Returns true if target is an existing directory. |
fs.isFile | fs.isFile(target: path) | bool | Returns true if target is a regular file. |
fs.isLocked | fs.isLocked(file: path) | bool | Probes CreateFileW with exclusive sharing (0) to check if another process holds a file lock. |
fs.size | fs.size(file: path) | int | Returns file size in bytes (0 if missing). |
fs.join | fs.join(part1: any, part2: any, ...) | path | Joins up to 8 path segments cleanly (functional equivalent of a / b). |
fs.parent | fs.parent(target: path) | path | Returns the parent directory path. |
fs.fileName | fs.fileName(target: path) | string | Returns filename including extension ("Workbench.exe"). |
fs.stem | fs.stem(target: path) | string | Returns filename without extension ("Workbench"). |
fs.ext | fs.ext(target: path) | string | Returns extension including leading dot (".exe"). |
fs.tempDir | fs.tempDir(subName?: string) | path | Resolves or allocates a scoped directory inside %TEMP%. |
fs.tempFile | fs.tempFile(prefix?: string, ext?: string) | path | Allocates a unique temporary file path. |
fs.fileVersion | fs.fileVersion(pePath: path) | version | Reads PE VS_FIXEDFILEINFO (GetFileVersionInfoW) as a 4-part SemVer value! |
fs.sha256 | fs.sha256(file: path) | string | Computes lowercase 64-char hex SHA-256 via Windows CNG bcrypt.dll. |
fs.verifyAuthenticode | fs.verifyAuthenticode(pePath: path) | bool | Verifies PE Authenticode signature chain via WinVerifyTrust(WINTRUST_ACTION_GENERIC_VERIFY_V2). |
fs.findFiles | fs.findFiles(dir: path, pattern?: string, recursive?: bool) | array | Enumerates matching file path items in dir. |
fs.readText | fs.readText(file: path) | string | Reads a UTF-8 text file (stripping optional UTF-8 BOM). |
fs.readLines | fs.readLines(file: path) | array | Reads UTF-8 lines into a string[] array. |
fs.readJson | fs.readJson(file: path) | any | Reads and parses a UTF-8 JSON file into maps/arrays/primitives. |
fs.* — Rollback-Journaled Mutations & RSWPAK1 Extraction (15 Methods)
| Method | Signature | Return | Rollback Behavior (.rsw-rollback.jnl) |
|---|---|---|---|
fs.writeText | fs.writeText(file: path, content: string) | bool | Snapshots existing file to .rswbak (or records created file for deletion on fault). |
fs.appendText | fs.appendText(file: path, text: string) | bool | Snapshots prior file bytes to .rswbak before appending. |
fs.writeJson | fs.writeJson(file: path, value: any, pretty?: bool) | bool | Atomically serializes structured JSON (with .rswbak protection). |
fs.writeBytesHex | fs.writeBytesHex(file: path, hexString: string) | bool | Writes decoded binary bytes with .rswbak rollback protection. |
fs.mkdir | fs.mkdir(dir: path) | bool | Creates missing parent/target directories and journals newly created folders in LIFO order. |
fs.copy | fs.copy(src: path, dst: path, overwrite?: bool) | bool | Copies src -> dst (overwrite = true default), backing up any prior dst to .rswbak. |
fs.copyTree | fs.copyTree(srcDir: path, dstDir: path, progressLabel?: string) | bool | Recursively copies an entire directory tree with per-file rollback entries. |
fs.move | fs.move(src: path, dst: path) | bool | Moves/renames src -> dst with rollback restoration. |
fs.remove | fs.remove(file: path) | bool | Backs up file to .rswbak during install so fault rollback restores deleted files! |
fs.removeDir | fs.removeDir(dir: path) | bool | Removes directory tree if present. |
fs.removeTree | fs.removeTree(dir: path) | bool | Alias for fs.removeDir(dir). |
fs.removeTreeIfExists | fs.removeTreeIfExists(dir: path) | bool | Safely removes dir without error when already absent. |
fs.setAttributes | fs.setAttributes(target: path, readOnly?: bool, hidden?: bool, system?: bool) | bool | Updates Win32 file attributes (SetFileAttributesW). |
fs.setNtfsCompression | fs.setNtfsCompression(target: path, enabled?: bool) | bool | Enables/disables transparent NTFS LZNT1 compression (FSCTL_SET_COMPRESSION). |
fs.extract | fs.extract(payloadId?: string, to?: path, feature?: string) | int | Extracts embedded LZMS RSWPAK1 (#220) files into to (default installDir), returning extracted file count! |
reg.* — Stateless 64-Bit & 32-Bit WOW64 Windows Registry (13 Methods)
| Method | Signature | Return | Mutating? | Description |
|---|---|---|---|---|
reg.exists | reg.exists(hive: string, key: string, valueName?: string, view?: string) | bool | Read-Only | Checks whether key (or valueName when non-empty) exists. |
reg.read | reg.read(hive: string, key: string, valueName: string, fallback?: any, view?: string) | any | Read-Only | Reads string or integer value—returning null when absent so ?? null-coalescing chains work naturally! |
reg.readString | reg.readString(hive: string, key: string, valueName: string, fallback?: string, view?: string) | string | Read-Only | Reads REG_SZ or REG_EXPAND_SZ string (returning fallback or "" when missing). |
reg.readDword | reg.readDword(hive: string, key: string, valueName: string, fallback?: int, view?: string) | int | Read-Only | Reads REG_DWORD or REG_QWORD integer. |
reg.listSubkeys | reg.listSubkeys(hive: string, key: string, view?: string) | array | Read-Only | Enumerates child subkey names as a string[] array (RegView.Both merges 64-bit & WOW6432Node!). |
reg.listValues | reg.listValues(hive: string, key: string, view?: string) | array | Read-Only | Enumerates value names under key as a string[] array. |
reg.write | reg.write(hive: string, key: string, valueName: string, value: any, view?: string) | bool | Mutating (RSW701) | Writes REG_SZ (for strings/paths) or REG_DWORD (for int/bool) with full prior-value rollback journaling. |
reg.writeString | reg.writeString(hive: string, key: string, valueName: string, value: string, view?: string) | bool | Mutating (RSW701) | Writes REG_SZ UTF-16 string value (rollback-journaled). |
reg.writeExpandString | reg.writeExpandString(hive: string, key: string, valueName: string, value: string, view?: string) | bool | Mutating (RSW701) | Writes REG_EXPAND_SZ unexpanded %VAR% string (rollback-journaled). |
reg.writeDword | reg.writeDword(hive: string, key: string, valueName: string, value: int, view?: string) | bool | Mutating (RSW701) | Writes 32-bit REG_DWORD value (rollback-journaled). |
reg.appendMultiString | reg.appendMultiString(hive: string, key: string, valueName: string, item: string, view?: string) | bool | Mutating (RSW701) | Idempotently appends item to a REG_MULTI_SZ list without duplicating existing entries. |
reg.deleteValue | reg.deleteValue(hive: string, key: string, valueName: string, view?: string) | bool | Mutating (RSW701) | Deletes valueName (prior value saved in .rsw-rollback.jnl for automatic restoration on fault). |
reg.deleteKeyTree | reg.deleteKeyTree(hive: string, key: string, view?: string) | bool | Mutating (RSW701) | Recursively deletes key (RegDeleteTreeW). |
// Clean null-coalescing lookup across HKCU -> 64-bit HKLM -> Program Files fallback!
let hostDir = reg.read(Hive.HKCU, r"Software\RaggieSoft\Book Reader", "Install Path")
?? reg.read(Hive.HKLM, r"SOFTWARE\RaggieSoft\Book Reader", "Install Path", view: RegView.Native64)
?? (sys.programFiles / "RaggieSoft" / "Book Reader");
fs.exists(path)Read-Only
fs.isDir(path)Read-Only
fs.isFile(path)Read-Only
fs.isLocked(file)Read-Only
fs.fileVersion(pePath)Read-Only
fs.sha256(file)Read-Only
fs.verifyAuthenticode(pePath)Read-Only
fs.findFiles(dir, pattern?, recursive?)Read-Only
fs.readText(file)Read-Only
fs.readJson(file)Read-Only
fs.writeText(file, content)Mutating
fs.writeJson(file, value, pretty?)Mutating
fs.mkdir(dir)Mutating
fs.copy(src, dst, overwrite?)Mutating
fs.copyTree(srcDir, dstDir, progressLabel?)Mutating
fs.move(src, dst)Mutating
fs.remove(file)Mutating
fs.removeDir(dir)Mutating
fs.setNtfsCompression(target, enabled?)Mutating
fs.extract(payloadId?, to?, feature?)Mutating
reg.exists(hive, key, valueName?, view?)Read-Only
reg.read(hive, key, valueName, fallback?, view?)Read-Only
reg.readString(hive, key, valueName, fallback?, view?)Read-Only
reg.readDword(hive, key, valueName, fallback?, view?)Read-Only
reg.listSubkeys(hive, key, view?)Read-Only
reg.listValues(hive, key, view?)Read-Only
reg.write(hive, key, valueName, value, view?)Mutating
reg.writeString(hive, key, valueName, value, view?)Mutating
reg.writeExpandString(hive, key, valueName, value, view?)Mutating
reg.writeDword(hive, key, valueName, value, view?)Mutating
reg.appendMultiString(hive, key, valueName, item, view?)Mutating
reg.deleteValue(hive, key, valueName, view?)Mutating
reg.deleteKeyTree(hive, key, view?)Mutating