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