pub fn scan_paths_recursively(dir: &str, stdout: &mut Stdout) -> Vec<String> {
    let mut list = Vec::new();
    let searches_root = String::from(dir).starts_with('.');

    match fs::read_dir(dir) {
        Ok(dir) => {
            for entry in dir {
                let entry = entry.unwrap();
                let is_dir = entry.metadata().unwrap().is_dir();
                let path = entry.path();
                let path = path.to_str().unwrap();

                if is_dir {
                    let submap = scan_paths_recursively(path, stdout);

                    for subpath in submap {
                        update_status(stdout, format!("Currently Scanning: {}", subpath));
                        list.push(subpath);
                    }
                } else {
                    let mut workable_path = String::from(path);

                    // If the current directory is selected (via "./"), then chop that part off.
                    if searches_root {
                        workable_path.drain(..2);
                    }

                    update_status(stdout, format!("Currently Scanning: {}", workable_path));
                    list.push(workable_path);
                }
            }
        }
        Err(_) => println!("Could not successfully read the directory \"{}\"!", dir),
    }

    list
}
// Scan a directory recursively and return all the paths.
Scan a directory recursively and return all the paths.
Scan a directory recursively and return all the paths .
pub fn scan_paths_recursively(dir: &str, stdout: &mut Stdout) -> Vec<String> {
    let mut list = Vec::new();
    let searches_root = String::from(dir).starts_with('.');
    match fs::read_dir(dir) {
        Ok(dir) => {
            for entry in dir {
                let entry = entry.unwrap();
                let is_dir = entry.metadata().unwrap().is_dir();
                let path = entry.path();
                let path = path.to_str().unwrap();
                if is_dir {
                    let submap = scan_paths_recursively(path, stdout);
                    for subpath in submap {
                        update_status(stdout, format!("Currently Scanning: {}", subpath));
                        list.push(subpath);
                    }
                } else {
                    let mut workable_path = String::from(path);
                    // If the current directory is selected (via "./"), then chop that part off.
                    if searches_root {
                        workable_path.drain(..2);
                    }
                    update_status(stdout, format!("Currently Scanning: {}", workable_path));
                    list.push(workable_path);
                }
            }
        }
        Err(_) => println!("Could not successfully read the directory \"{}\"!", dir),
    }
    list
}
pub fn scan_paths_recursively ( dir : & str , stdout : & mut Stdout ) -> Vec < String > { let mut list = Vec :: new ( ) ; let searches_root = String :: from ( dir ) . starts_with ( '.' ) ; match fs :: read_dir ( dir ) { Ok ( dir ) => { for entry in dir { let entry = entry . unwrap ( ) ; let is_dir = entry . metadata ( ) . unwrap ( ) . is_dir ( ) ; let path = entry . path ( ) ; let path = path . to_str ( ) . unwrap ( ) ; if is_dir { let submap = scan_paths_recursively ( path , stdout ) ; for subpath in submap { update_status ( stdout , format ! ( " " subpath ) ) ; list . push ( subpath ) ; } } else { let mut workable_path = String :: from ( path ) ; // If the current directory is selected (via "./"), then chop that part off. if searches_root { workable_path . drain ( .. 2 ) ; } update_status ( stdout , format ! ( " " workable_path ) ) ; list . push ( workable_path ) ; } } } Err ( _ ) => println ! ( " \" \" " dir ) , } list }
Scan a directory recursively and return all the paths.
Scan a directory recursively and return all the paths .
dir
&str
stdout
&mut Stdout
dir
&str
stdout
&mut Stdout