Files
swagger-cli/src/utils.rs

17 lines
455 B
Rust

use std::path::Path;
/// Compute total size of files in a directory (non-recursive, skips symlinks).
///
/// Used by doctor and cache commands to report disk usage per alias.
pub fn dir_size(path: &Path) -> u64 {
let Ok(entries) = std::fs::read_dir(path) else {
return 0;
};
entries
.filter_map(Result::ok)
.filter_map(|e| e.metadata().ok())
.filter(|m| m.is_file())
.map(|m| m.len())
.sum()
}