<commit_before>extern crate nes_emulator;

use nes_emulator::rom::Rom;

use std::path::Path;
use std::env;
use std::fs;
use std::fs::*;
use std::io;
use std::collections::HashSet;

fn visit_dirs(dir: &Path, cb: &mut FnMut(&DirEntry)) -> io::Result<()> {
    if try!(fs::metadata(dir)).is_dir() {
        for entry in try!(fs::read_dir(dir)) {
            let entry = try!(entry);
            if try!(fs::metadata(entry.path())).is_dir() {
                try!(visit_dirs(&entry.path(), cb));
            } else {
                cb(&entry);
            }
        }
    }
    Ok(())
}

fn scan_dirs() -> io::Result<()> {
    let args = env::args();
    let path_str = args.skip(1).next().unwrap();
    let path = Path::new( &path_str );
    let mut mappers : HashSet<u8> = HashSet::new();
    let result = visit_dirs( path, &mut |file: &DirEntry| {
        let path = file.path();
        match path.extension().and_then( |ext| ext.to_str() ) {
            Some("NES") | Some( "nes" ) => {
                println!( "{}", path.to_str().unwrap() );
                match Rom::read( &path ) {
                    Ok(ref rom) => {
                        println!( "PRG Size: {}, CHR Size: {}, PRG_RAM Size:{}, trainer size: {}", rom.prg_rom().len(), rom.chr_rom().len(), rom.prg_ram.len(), rom.trainer.len() );
                        println!( "SRAM:{}, Screen Mode: {:?}, PC10: {}, VS: {}, Mapper: {}", rom.sram(), rom.screen_mode(), rom.pc10(), rom.vs(), rom.mapper() );
                        mappers.insert( rom.mapper() );
                    }
                    Err(ref err) => println!( "{}", err )
                };
                println!("");
            }
            _ => ()
        };
    });
    let mut mappers : Vec<u8> = mappers.iter().cloned().collect();
    mappers.sort();
    println!("Mappers: {:?}", mappers);
    result
}

fn main() {
    scan_dirs().ok().unwrap();
}
<commit_msg>Fix compile errors in scanner.<commit_after>extern crate nes_emulator;

use nes_emulator::rom::Rom;

use std::path::Path;
use std::env;
use std::fs;
use std::fs::*;
use std::io;
use std::collections::HashSet;

fn visit_dirs(dir: &Path, cb: &mut FnMut(&DirEntry)) -> io::Result<()> {
    if try!(fs::metadata(dir)).is_dir() {
        for entry in try!(fs::read_dir(dir)) {
            let entry = try!(entry);
            if try!(fs::metadata(entry.path())).is_dir() {
                try!(visit_dirs(&entry.path(), cb));
            } else {
                cb(&entry);
            }
        }
    }
    Ok(())
}

fn scan_dirs() -> io::Result<()> {
    let args = env::args();
    let path_str = args.skip(1).next().unwrap();
    let path = Path::new( &path_str );
    let mut mappers : HashSet<u8> = HashSet::new();
    let result = visit_dirs( path, &mut |file: &DirEntry| {
        let path = file.path();
        match path.extension().and_then( |ext| ext.to_str() ) {
            Some("NES") | Some( "nes" ) => {
                println!( "{}", path.to_str().unwrap() );
                match Rom::read( &path ) {
                    Ok(ref rom) => {
                        println!( "PRG Size: {}, CHR Size: {}, PRG_RAM Size:{}, trainer size: {}", rom.prg_rom.len(), rom.chr_rom.len(), rom.prg_ram.len(), rom.trainer.len() );
                        println!( "SRAM:{}, Screen Mode: {:?}, PC10: {}, VS: {}, Mapper: {}", rom.sram(), rom.screen_mode(), rom.pc10(), rom.vs(), rom.mapper() );
                        mappers.insert( rom.mapper() );
                    }
                    Err(ref err) => println!( "{}", err )
                };
                println!("");
            }
            _ => ()
        };
    });
    let mut mappers : Vec<u8> = mappers.iter().cloned().collect();
    mappers.sort();
    println!("Mappers: {:?}", mappers);
    result
}

fn main() {
    scan_dirs().ok().unwrap();
}

{'fraction_non_alphanumeric': 0.20432878124194795, 'fraction_numerical': 0.003607317701623293, 'mean_word_length': 1.9100449775112445, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '2836925', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1272, 'n_words': 256}