filesize

Cargo Build Status

Physical disk space use retrieval.

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.

Supported Platforms

Unix

On Unix platforms this is a thin wrapper around [std::fs::symlink_metadata()] and [std::os::unix::fs::MetadataExt], simply returning blocks() * 512.

Windows

On Windows this wraps [GetCompressedFileSizeW()].

Everything Else

All other platforms receive a fallback that simply returns the logical file size.