fn check_files_in_subfolder(dir_selected:&str,num_folders_with_files:&mut usize,file_log:&mut File)->Result<usize,std::io::Error>{
    let mut file_exist=false;
    let mut not_ascii=false;
    let mut count_max=0;
    for path in std::fs::read_dir(&dir_selected).unwrap() {
        match path{
            Ok(path_ok)=>{
                match path_ok.file_type() {
                    Ok(file_type_ok) => {
                        match file_type_ok.is_file() {
                            true => {
                                match file_exist{
                                    true=>(),
                                    false=>{
                                        file_exist=true
                                    },
                                }
                            },
                            false => (),
                        }
                    },
                    Err(e) => println!("{:?}", e),
                }
            },
            Err(e)=>println!("{:?}", e)
        }
    }
    match file_exist{
        true=>{
            *num_folders_with_files=1;
            for path in std::fs::read_dir(&dir_selected).unwrap() {
                match path{
                    Ok(path_ok)=>{
                        match path_ok.file_type() {
                            Ok(file_type_ok)=>{
                                match file_type_ok.is_dir(){
                                    true => {
                                        match if_ascii(&path_ok.path().to_str().unwrap()){
                                            true=>{
                                            },
                                            false=>{
                                                not_ascii=true;
                                                file_log.write_all(format!("NOT_ASCII(rename to english):{:?}\r\n", &path_ok.path().to_str().unwrap()).as_bytes()).unwrap_or(());
                                            },
                                        }
                                        match check_files_in_subfolder(&path_ok.path().to_str().unwrap(),num_folders_with_files,file_log){
                                            Ok(_i)=>{
                                                *num_folders_with_files+=1;
                                            },
                                            Err(_e)=>not_ascii=true,
                                        }
                                    },
                                    false => {
                                        match if_ascii(&path_ok.path().to_str().unwrap()){
                                            true=>{ 
                                            },
                                            false=>{
                                                not_ascii=true;
                                                file_log.write_all(format!("NOT_ASCII(rename to english):{:?}\r\n", &path_ok.path().to_str().unwrap()).as_bytes()).unwrap_or(());
                                            },
                                        }
                                    },
                                }
                            },
                            Err(e)=>println!("{:?}", e)
                        }
                    },
                    Err(e)=>println!("{:?}", e)
                }
                if num_folders_with_files>&mut count_max{
                    count_max=*num_folders_with_files;
                } 
            }
        },
        false=>()
    }
    match not_ascii {
        true => Err(std::io::Error::new(std::io::ErrorKind::Other, "Not ascii, all files or folders writed to LOG_rling.txt")),
        false => Ok(count_max),
    }
    
}
//Check subfolders
//return depth of lying files
//if the folder does not contain file - skip subfolders
Check subfolders
return depth of lying files
if the folder does not contain file - skip subfolders
Check subfolders return depth of lying files if the folder does not contain file - skip subfolders
fn check_files_in_subfolder(dir_selected:&str,num_folders_with_files:&mut usize,file_log:&mut File)->Result<usize,std::io::Error>{
    let mut file_exist=false;
    let mut not_ascii=false;
    let mut count_max=0;
    for path in std::fs::read_dir(&dir_selected).unwrap() {
        match path{
            Ok(path_ok)=>{
                match path_ok.file_type() {
                    Ok(file_type_ok) => {
                        match file_type_ok.is_file() {
                            true => {
                                match file_exist{
                                    true=>(),
                                    false=>{
                                        file_exist=true
                                    },
                                }
                            },
                            false => (),
                        }
                    },
                    Err(e) => println!("{:?}", e),
                }
            },
            Err(e)=>println!("{:?}", e)
        }
    }
    match file_exist{
        true=>{
            *num_folders_with_files=1;
            for path in std::fs::read_dir(&dir_selected).unwrap() {
                match path{
                    Ok(path_ok)=>{
                        match path_ok.file_type() {
                            Ok(file_type_ok)=>{
                                match file_type_ok.is_dir(){
                                    true => {
                                        match if_ascii(&path_ok.path().to_str().unwrap()){
                                            true=>{
                                            },
                                            false=>{
                                                not_ascii=true;
                                                file_log.write_all(format!("NOT_ASCII(rename to english):{:?}\r\n", &path_ok.path().to_str().unwrap()).as_bytes()).unwrap_or(());
                                            },
                                        }
                                        match check_files_in_subfolder(&path_ok.path().to_str().unwrap(),num_folders_with_files,file_log){
                                            Ok(_i)=>{
                                                *num_folders_with_files+=1;
                                            },
                                            Err(_e)=>not_ascii=true,
                                        }
                                    },
                                    false => {
                                        match if_ascii(&path_ok.path().to_str().unwrap()){
                                            true=>{ 
                                            },
                                            false=>{
                                                not_ascii=true;
                                                file_log.write_all(format!("NOT_ASCII(rename to english):{:?}\r\n", &path_ok.path().to_str().unwrap()).as_bytes()).unwrap_or(());
                                            },
                                        }
                                    },
                                }
                            },
                            Err(e)=>println!("{:?}", e)
                        }
                    },
                    Err(e)=>println!("{:?}", e)
                }
                if num_folders_with_files>&mut count_max{
                    count_max=*num_folders_with_files;
                } 
            }
        },
        false=>()
    }
    match not_ascii {
        true => Err(std::io::Error::new(std::io::ErrorKind::Other, "Not ascii, all files or folders writed to LOG_rling.txt")),
        false => Ok(count_max),
    }
}
fn check_files_in_subfolder ( dir_selected : & str , num_folders_with_files : & mut usize , file_log : & mut File ) -> Result < usize , std :: io :: Error > { let mut file_exist = false ; let mut not_ascii = false ; let mut count_max = 0 ; for path in std :: fs :: read_dir ( & dir_selected ) . unwrap ( ) { match path { Ok ( path_ok ) => { match path_ok . file_type ( ) { Ok ( file_type_ok ) => { match file_type_ok . is_file ( ) { true => { match file_exist { true => ( ) , false => { file_exist = true } , } } , false => ( ) , } } , Err ( e ) => println ! ( " " e ) , } } , Err ( e ) => println ! ( " " e ) } } match file_exist { true => { * num_folders_with_files = 1 ; for path in std :: fs :: read_dir ( & dir_selected ) . unwrap ( ) { match path { Ok ( path_ok ) => { match path_ok . file_type ( ) { Ok ( file_type_ok ) => { match file_type_ok . is_dir ( ) { true => { match if_ascii ( & path_ok . path ( ) . to_str ( ) . unwrap ( ) ) { true => { } , false => { not_ascii = true ; file_log . write_all ( format ! ( " \r \n " path_ok path ( ) to_str ( ) unwrap ( ) ) . as_bytes ( ) ) . unwrap_or ( ( ) ) ; } , } match check_files_in_subfolder ( & path_ok . path ( ) . to_str ( ) . unwrap ( ) , num_folders_with_files , file_log ) { Ok ( _i ) => { * num_folders_with_files += 1 ; } , Err ( _e ) => not_ascii = true , } } , false => { match if_ascii ( & path_ok . path ( ) . to_str ( ) . unwrap ( ) ) { true => { } , false => { not_ascii = true ; file_log . write_all ( format ! ( " \r \n " path_ok path ( ) to_str ( ) unwrap ( ) ) . as_bytes ( ) ) . unwrap_or ( ( ) ) ; } , } } , } } , Err ( e ) => println ! ( " " e ) } } , Err ( e ) => println ! ( " " e ) } if num_folders_with_files > & mut count_max { count_max = * num_folders_with_files ; } } } , false => ( ) } match not_ascii { true => Err ( std :: io :: Error :: new ( std :: io :: ErrorKind :: Other , " " ) ) , false => Ok ( count_max ) , } }
Check subfolders
return depth of lying files
if the folder does not contain file - skip subfolders
Check subfolders return depth of lying files if the folder does not contain file - skip subfolders
dir_selected
&str
num_folders_with_files
&mut usize
file_log
&mut File