We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hey, I meet a proble, here is a directory vue-frontend, and when calling cargo wipe node in the directory
vue-frontend
cargo wipe node
but when I call the find . type f | wc -l
find . type f | wc -l
the file_counts are not the same at all,
I have some function that modify from your code,
pub fn dir_size(path: impl Into<PathBuf>) -> io::Result<DirInfo> { let mut visited = HashSet::new(); dir_size_0(path, &mut visited) } fn dir_size_0(path: impl Into<PathBuf>, visited: &mut HashSet<String>) -> io::Result<DirInfo> { let mut dir_info = DirInfo::new(0, 0, 0); let targetpath: PathBuf = path.into(); for entry in WalkDir::new(&targetpath).max_depth(1) { let entry = entry?; let filepath = entry.path().display().to_string(); if filepath == "." || filepath == "./" || filepath == targetpath.display().to_string() { continue; } if entry.file_type().is_dir() && !visited.contains(&filepath) { visited.insert(filepath.clone()); let child_dir_info = dir_size_0(&filepath, visited)?; dir_info.dir_count += child_dir_info.dir_count + 1; dir_info.file_count += child_dir_info.file_count; dir_info.size += child_dir_info.size; } else { let file = File::open(&filepath)?; let metadata = file.metadata()?; dir_info.file_count += 1; dir_info.size += metadata.len() as usize; } } Ok(dir_info) }
and the test resuls is
I am a little confused now, what is the matter with my code, or your code ?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
hey, I meet a proble, here is a directory
vue-frontend
, and when callingcargo wipe node
in the directorybut when I call the
find . type f | wc -l
the file_counts are not the same at all,
I have some function that modify from your code,
and the test resuls is
I am a little confused now, what is the matter with my code, or your code ?
The text was updated successfully, but these errors were encountered: