@@ -10,12 +10,8 @@ struct Args {
|
||||
|
||||
fn compute_size(path: PathBuf) -> Result<u64, std::io::Error> {
|
||||
if path.is_dir() {
|
||||
std::fs::read_dir(path)?.fold(Ok(0_u64), |counter, entry| -> Result<u64, std::io::Error> {
|
||||
if let Ok(counter) = counter {
|
||||
std::fs::read_dir(path)?.try_fold(0_u64, |counter, entry| -> Result<u64, std::io::Error> {
|
||||
Ok(counter + compute_size(entry?.path())?)
|
||||
} else {
|
||||
counter
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Ok(std::fs::metadata(path)?.len())
|
||||
|
||||
Reference in New Issue
Block a user