<commit_before><commit_msg>Experimental copy_files.rs<commit_after>use std::env::args as cmd_args;
use std::fs::{read_dir, metadata};
use std::collections::HashSet;
use std::path::{PathBuf, Path};

#[inline(always)]
fn usage() {
    println!("Usage: copy_files [source dir] [dest dir]");
}

#[inline(always)]
fn dir_check(dir: &String) -> bool {
    if let Ok(source_metadata) = metadata(&dir) {
        return source_metadata.is_dir();
    }
    false
}

fn main() {
    if cmd_args().len() < 3 { return usage(); }

    let source_dir = cmd_args().skip(1).next().unwrap();
    let dest_dir = cmd_args().skip(2).next().unwrap();

    if source_dir == dest_dir {
        println!(">>>Both destination and source directories are the same");
        return;
    }
    else if !dir_check(&source_dir) {
        println!(">>>{}: is not a directory or there is no such directory", &source_dir);
        return;
    }
    else if !dir_check(&dest_dir) {
        println!(">>>{}: is not a directory or there is no such directory", &dest_dir);
        return;
    }

    let dest_files: HashSet<PathBuf> = read_dir(&dest_dir).unwrap()
                                                          .map(|elem| elem.unwrap().path())
                                                          .filter(|elem| metadata(elem).unwrap().is_file())
                                                          .collect();
    let source_files: HashSet<PathBuf> = read_dir(&source_dir).unwrap()
                                                             .map(|elem| elem.unwrap().path())
                                                             .filter(|elem| metadata(elem).unwrap().is_file())
                                                             .collect();
    drop(source_files);
    println!("{:?}", dest_files);
}
{'fraction_non_alphanumeric': 0.14673311184939092, 'fraction_numerical': 0.0016611295681063123, 'mean_word_length': 1.7842835130970724, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '722394', 'n_tokens_mistral': 479, 'n_tokens_neox': 483, 'n_words': 112}