<commit_before>use std::io::fs;
use std::io::File;
use std::collections::HashMap;
use std::os;

fn examine_files(directory_path: &Path, map: &mut HashMap<(u64,u64), Box<String>>) {

    let entries = fs::readdir(directory_path);

    if !entries.is_ok() {
        return;
    }

    for entry in entries.unwrap().iter() {
        if entry.is_dir() {
            examine_files(entry, map);
        } else {
            let path = entry.as_str().unwrap();
            let stat = entry.stat();
            if stat.is_ok() {
                let unwrapped_stat = stat.unwrap();
                map.insert((unwrapped_stat.size, unwrapped_stat.modified), box path.to_string());
            }
        }
    }
}

fn compare_files(src_path: Path, new_path: Path) -> bool {
    let mut src_file = File::open(&src_path);
    let mut new_file = File::open(&new_path);
    let src_data = src_file.read_to_end();
    let new_data = new_file.read_to_end();

    src_data == new_data
}

fn main() {

    let args = os::args();

    if args.len() != 3 {
        println!("Usage: {} <original-directory> <new-directory>", args[0]);
        return;
    }

    let src_directory = Path::new(args[1].clone());
    let dst_directory = Path::new(args[2].clone());
        
    let mut src_map = HashMap::<(u64, u64), Box<String>>::new();
    examine_files(&Path::new(src_directory), &mut src_map);
    let mut new_map = HashMap::<(u64, u64), Box<String>>::new();
    examine_files(&Path::new(dst_directory), &mut new_map);
    for (key, value) in new_map.iter() {
        if src_map.contains_key(key) {
            let src_path = *(src_map.get(key).clone());
            let new_path = *(value.clone());
            if compare_files(Path::new(src_path.clone()), Path::new(new_path.clone())) {
                println!("{} was renamed to {}", src_path, new_path);
            }
        }
    }
}<commit_msg>Show relative paths in changelog<commit_after>use std::io::fs;
use std::io::File;
use std::collections::HashMap;
use std::os;

fn examine_files(directory_path: &Path, map: &mut HashMap<(u64,u64), Box<String>>) {

    let entries = fs::readdir(directory_path);

    if !entries.is_ok() {
        return;
    }

    for entry in entries.unwrap().iter() {
        if entry.is_dir() {
            examine_files(entry, map);
        } else {
            let path = entry.as_str().unwrap();
            let stat = entry.stat();
            if stat.is_ok() {
                let unwrapped_stat = stat.unwrap();
                map.insert((unwrapped_stat.size, unwrapped_stat.modified), box path.to_string());
            }
        }
    }
}

fn compare_files(src_path: Path, new_path: Path) -> bool {
    let mut src_file = File::open(&src_path);
    let mut new_file = File::open(&new_path);
    let src_data = src_file.read_to_end();
    let new_data = new_file.read_to_end();

    src_data == new_data
}

fn main() {

    let args = os::args();

    if args.len() != 3 {
        println!("Usage: {} <original-directory> <new-directory>", args[0]);
        return;
    }

    let src_directory = Path::new(args[1].clone());
    let dst_directory = Path::new(args[2].clone());
        
    let mut src_map = HashMap::<(u64, u64), Box<String>>::new();
    examine_files(&Path::new(src_directory.clone()), &mut src_map);
    let mut new_map = HashMap::<(u64, u64), Box<String>>::new();
    examine_files(&Path::new(dst_directory.clone()), &mut new_map);
    for (key, value) in new_map.iter() {
        if src_map.contains_key(key) {
            let src_path = Path::new(*src_map.get(key).clone());
            let new_path = Path::new(*value.clone());
            if compare_files(src_path.clone(), new_path.clone()) {
                println!("{} was renamed to {}", 
                         src_path.path_relative_from(&src_directory).unwrap().as_str().unwrap(), 
                         new_path.path_relative_from(&dst_directory).unwrap().as_str().unwrap());
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.16519768320322337, 'fraction_numerical': 0.008058423570888944, 'mean_word_length': 2.5880758807588076, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3252851', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1305, 'n_words': 256}