letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
letmutfolders_to_check: Vec<PathBuf>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
// TODO maybe add multithreading checking for file hash
letstart_time: SystemTime=SystemTime::now();
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
letmutfolders_to_check: Vec<PathBuf>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
file.write_all(b"-------------------------------------------------Files with same hashes-------------------------------------------------\n").unwrap();
file.write_all(
format!(
"Found {} duplicated files which in {} groups which takes {}.\n",
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
letmutfolders_to_check: Vec<PathBuf>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
/// If directory contains only 2 empty folders, then this directory should be removed instead two empty folders inside because it will produce another empty folder.
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
letmutfolders_to_check: Vec<PathBuf>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
// Loop to recursively set as non empty this and all his parent folders
loop{
d.is_empty=FolderEmptiness::No;
ifd.parent_path!=None{
cf=d.parent_path.clone().unwrap();
letcf=d.parent_path.clone().unwrap();
d=folders_checked.get_mut(&cf).unwrap();
}else{
break;
@ -215,11 +206,6 @@ impl EmptyFolder {
#[allow(unused_mut)]// Used is later by Windows build
for(mutname,folder_entry)infolders_checked{
iffolder_entry.is_empty!=FolderEmptiness::No{
#[cfg(target_family = "windows")]
{
name=Common::prettier_windows_path(&name);
}
self.empty_folder_list.insert(name,folder_entry);
}
}
@ -235,7 +221,7 @@ impl EmptyFolder {
fornameinself.empty_folder_list.keys(){
matchfs::remove_dir_all(name){
Ok(_)=>(),
Err(_)=>self.text_messages.warnings.push(format!("Failed to remove folder {}",name)),
Err(_)=>self.text_messages.warnings.push(format!("Failed to remove folder {}",name.display())),
};
}
@ -285,22 +271,19 @@ impl SaveResults for EmptyFolder {
}
};
matchfile.write_all(format!("Results of searching {:?} with excluded directories {:?}\n",self.directories.included_directories,self.directories.excluded_directories).as_bytes()){
Ok(_)=>(),
Err(_)=>{
self.text_messages.errors.push("Failed to save results to file ".to_string()+file_name.as_str());
returnfalse;
}
ifwriteln!(file,"Results of searching {:?} with excluded directories {:?}",self.directories.included_directories,self.directories.excluded_directories).is_err(){
self.text_messages.errors.push("Failed to save results to file ".to_string()+file_name.as_str());
letmutfolders_to_check: Vec<String>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
letmutfolders_to_check: Vec<PathBuf>=Vec::with_capacity(1024*2);// This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector