Expand description
File metadata operations including size calculation, checksums, and file queries.
This module provides functions for:
- Directory size calculation (recursive)
- SHA-256 checksum generation (single and parallel)
- File existence and readability checks
- File modification time queries and comparisons
§Examples
use agpm_cli::utils::fs::metadata::{calculate_checksum, dir_size, file_exists_and_readable};
use std::path::Path;
// Check if file is readable
if file_exists_and_readable(Path::new("important.txt")) {
// Calculate checksum for integrity verification
let checksum = calculate_checksum(Path::new("important.txt"))?;
println!("File checksum: {}", checksum);
}
// Calculate directory size
let size = dir_size(Path::new("cache"))?;
println!("Cache size: {} bytes", size);Functions§
- calculate_
checksum - Calculates the SHA-256 checksum of a file.
- calculate_
checksums_ parallel - Calculates SHA-256 checksums for multiple files concurrently.
- compare_
file_ times - Compares the modification times of two files.
- dir_
size - Calculates the total size of a directory and all its contents recursively.
- file_
exists_ and_ readable - Checks if a file exists and is readable.
- get_
directory_ size - Asynchronously calculates the total size of a directory and all its contents.
- get_
modified_ time - Gets the modification time of a file.