1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
mod parser; use super::{Script, Command, Cmd}; use parser::take_file; use std::fs::File; use std::io::prelude::*; use std::path::Path; pub struct MscsbFile { pub scripts: Vec<Script>, pub strings: Vec<String>, pub entrypoint: u32, } impl MscsbFile { pub fn open<P: AsRef<Path>>(path: P) -> Option<MscsbFile> { let mut buffer = Vec::new(); File::open(path).ok()?.read_to_end(&mut buffer).ok()?; Some(take_file(&buffer[..]).unwrap().1) } pub fn iter(&self) -> std::slice::Iter<Script> { self.scripts.iter() } }