originaly made for eza --total-size
, but cant make it build cross-plarform, so it just work standalone on mac m1 as of now
How can finder display dir sizes instantly, but in userland it takes forever to walk through the file tree?
Its ovbious macos caches dir sizes somewhere but Apple dont expose any api or document this
It's only accessible through AppleScript's getinfo
methods, which I've made the first version with. However, it's slow and requires spawning a new process for each call. so this is what i came up with:
- libfffs: An attempt to reverse-engineer the underlying system call.
- dx-cli: A wrapper around libfffs to provide a
du -sh
-type interface and Rust FFI bindings.
The system provides three strategies that will fallback the following order by default:
-
AEV (AppleEvents): A long-forgotten IPC protocol using C with Pascal strings. It works well but sometimes fails on concurrent calls.
-
Dstore:
.ds_store
are binary dumps of Finder's internal database. Finder regenerates it even if the AEV call fails, so the combination of the two is surprisingly reliable. -
Live: Falls back to a classic recursive walkthrough of the file tree, which is safe and reliable but slow.
-
Osa: (legacy) Original applescript (osascript) implementation, still here for perfs benchmarking
Few parser attempts have been made since the OG chad that first reverse-engineered it, but on some more recent osx version it fails attempting to parse the entire B-tree
I've made a simpler implementation that only focuses on 1st level size and dates metadata and works on every .ds_store
found in GitHub Code Search.
its available in the lib as dstore_parser
dx 0.3.1
USAGE:
dx [FLAGS] [OPTIONS] [--] [PATH]...
FLAGS:
-b, --bytes Bytes
--dironly directory only
-h, --help Prints help information
-l, --list List
-p, --perf Performance
--sort Sort by size
--trace Traces
-V, --version Prints version information
-v, --verbose
OPTIONS:
--color <color> [default: auto] [possible values: auto, always, never]
-s, --strategy <strategy>... [possible values: aev, dstore, live, osa]
ARGS:
<PATH>... Paths [default: ./]