Expand description
decmpfs — apply the operating system’s transparent per-file compression to a file
in place: macOS APFS (decmpfs), Linux btrfs, Windows NTFS. The kernel decompresses
on read, so the file keeps its logical size + exact contents and loads at near-native
speed while taking less space on disk.
compress_file(path) detects the filesystem, applies compression, then verifies the
kernel reads the bytes back identically — rolling back on any failure. probe(path)
is the detect-only / capability-reporting half.
Backends: btrfs (FS_COMPR_FL + the btrfs.compression property), NTFS
(FSCTL_SET_COMPRESSION), and macOS decmpfs (resource fork, kernel-roundtrip
verified); other targets report Unsupported.
Contract: every Outcome is a SUCCESS; Err is reserved for genuine I/O failures
that leave the file’s integrity unknown. An unsupported FS, a permission/lock issue,
an incompressible or too-large file are non-fatal Outcomes.
Panic-free invariant: the deny below keeps non-test code free of the obvious panic sources; all slice indexing is length-guarded.
Structs§
- Decmpfs
Writer - An atomic incremental writer for OS-transparent filesystem compression.
- Gate
- The install-time gate: an optional glob AND an optional size predicate. A file
matches only if BOTH present predicates pass (an absent half is vacuously true).
Gate::default()is the fleet default — glob**/*.node, no size floor. - RmOptions
- Node
fs.rmoptions — same four fields, same defaults, nothing extra. - Stat
- Filesystem-compression state of a path — one call that coalesces the
otherwise-separate size + backend-signal reads (the compress/copy paths
previously did a
statAND anlstat/attr read per file). Follows symlinks: compression is a property of the target file, never a symlink.
Enums§
- Copy
Outcome - What a
copy_filedid — a SUCCESS shape, same contract asOutcome:Erris reserved for genuine I/O failures; the copy itself always lands. - Error
- Genuine failures only. A capability/permission gap is an
Outcome, not anError. - Gate
Parse Error - Why a
Gate/SizePredicatestring failed to parse. - Outcome
- What happened to the file. Only
Erris a hard failure. - Size
Predicate - A
>/>=comparison against a byte threshold. - Skip
Reason - Support
- Unsupported
Reason
Constants§
- DEFAULT_
GLOB - The fleet default — every native addon, regardless of size.
Functions§
- compress_
bytes - THE install-time entry point: write
contenttopathas an OS-compressed file in ONE pass — never a write-then-read-back-recompress. - compress_
file - THE entry point: detect → gate → apply → verify → rollback-on-failure. Idempotent. Never panics. Never corrupts the file.
- copy_
file - Copy
srctodestpreserving transparent filesystem compression — thefs.copyFilethe OS never shipped. A plain byte copy silently re-inflates a compressed file (the kernel hands every reader the full logical bytes, and that is what gets written back out); this copy keeps the on-disk savings. - probe
- Detect-only, no mutation — for dry-run / capability reporting.
- rm
- Node
fs.rm(path, options). A file/symlink is a single unlink. A directory needsrecursive(elseEISDIR, as in Node); recursive delete isstd::fs::remove_dir_all— MEASURED as the floor on APFS. - stat
- Inspect the FS-compression state of
path(seeStat). - try_
clone_ file - Attempt a copy-on-write clone of
srcatdest(clonefile(2)on macOS, theFICLONEioctl on Linux) — the zero-cost way to copy a compressed file WITH its compression.Ok(true)= cloned;Ok(false)= this pairing can’t clone (cross-volume, non-reflink FS, an existing destination on macOS, Windows) and the caller decides the fallback —copy_fileis the clone-then-fallback composition, and a Node-COPYFILE_FICLONE_FORCE-shaped caller turnsfalseinto its error.