/// Generate a listing of all the osu beatmaps in a particular directory
Generate a listing of all the osu beatmaps in a particular directory
Generate a listing of all the osu beatmaps in a particular directory
pub fn gen_song_list<P: AsRef<Path>>(path: P) -> Result<Vec<super::ChartSet>, io::Error> {
    let mut index = Vec::new();
    for dir_entry in std::fs::read_dir(path)? {
        let path = dir_entry?.path();
        if !path.is_dir() {
            continue;
        }
        let mut chart_set = super::ChartSet::default();
        for entry in std::fs::read_dir(path)? {
            let path = entry?.path();
            if !(path.extension()
                .unwrap_or("".as_ref())
                .to_string_lossy()
                .to_ascii_lowercase() == "osu") {
                continue;
            }
            match from_path_impl(&path) {
                Ok(c) => {
                    chart_set.difficulties.push(super::Difficulty {
                        name: c.difficulty_name,
                        path,
                    });
                    chart_set.creator = c.creator;
                    chart_set.artist = c.artist;
                    chart_set.artist_unicode = c.artist_unicode;
                    chart_set.song_name = c.song_name;
                    chart_set.song_name_unicode = c.song_name_unicode;
                }
                // Err(e) => remani_warn!("Error parsing osu file `{}': {}", path.display(), e),
                Err(_) => (), // ignore for now since they're annoying
            }
        }
        if chart_set != super::ChartSet::default() {
            index.push(chart_set);
        }
    }
    Ok(index)
}
pub fn gen_song_list < P : AsRef < Path > > ( path : P ) -> Result < Vec < super :: ChartSet > , io :: Error > { let mut index = Vec :: new ( ) ; for dir_entry in std :: fs :: read_dir ( path ) ? { let path = dir_entry ? . path ( ) ; if ! path . is_dir ( ) { continue ; } let mut chart_set = super :: ChartSet :: default ( ) ; for entry in std :: fs :: read_dir ( path ) ? { let path = entry ? . path ( ) ; if ! ( path . extension ( ) . unwrap_or ( " " . as_ref ( ) ) . to_string_lossy ( ) . to_ascii_lowercase ( ) == " " ) { continue ; } match from_path_impl ( & path ) { Ok ( c ) => { chart_set . difficulties . push ( super :: Difficulty { name : c . difficulty_name , path , } ) ; chart_set . creator = c . creator ; chart_set . artist = c . artist ; chart_set . artist_unicode = c . artist_unicode ; chart_set . song_name = c . song_name ; chart_set . song_name_unicode = c . song_name_unicode ; } // Err(e) => remani_warn!("Error parsing osu file `{}': {}", path.display(), e), Err ( _ ) => ( ) , // ignore for now since they're annoying } } if chart_set != super :: ChartSet :: default ( ) { index . push ( chart_set ) ; } } Ok ( index ) }
Generate a listing of all the osu beatmaps in a particular directory
Generate a listing of all the osu beatmaps in a particular directory
path
P