map-parser 0.1.5

A library for parsing and converting maps from vsrg games.
Documentation
use super::qua::QuaverMap;
use std::collections::HashMap;
use std::io::Read;
use zip;

#[derive(Debug)]
pub struct QuaverMapset {
    pub maps: HashMap<String, QuaverMap>,
}

impl QuaverMapset {
    pub fn from_path(path: &str) -> Self {
        let mut self_ = Self {
            maps: HashMap::new(),
        };

        let qp_file = std::fs::File::open(path).unwrap();

        let zip = zip::ZipArchive::new(&qp_file).unwrap();

        for name in zip.file_names() {
            if name.contains(".qua") {
                let mut contents = String::new();
                let mut zip = zip::ZipArchive::new(&qp_file).unwrap();
                let mut qua_file = zip.by_name(name).unwrap();
                qua_file.read_to_string(&mut contents).unwrap();
                self_
                    .maps
                    .insert(name.replace(".qua", ""), QuaverMap::from_string(&contents));
            }
        }

        self_
    }
}