filesize
abstracts platform-specific methods of determining the real space used
by files, taking into account filesystem compression and sparse files.
```rust use filesize::{filerealsize, filerealsize_fast};
let realsize = filerealsize("Cargo.toml")?;
// Save a stat() on Unix let alsorealsize = filerealsizefast( "Cargo.toml", &std::fs::symlink_metadata("Cargo.toml")? )?; ```
Now, please stop writing du
clones that only take apparent size into account.
On Unix platforms this is a thin wrapper around [std::fs::symlink_metadata()
]
and [std::os::unix::fs::MetadataExt
], simply returning blocks() * 512
.
On Windows this wraps [GetCompressedFileSizeW()
].
All other platforms receive a fallback that simply returns the logical file size.