diff formats/src/bin/dump_ecl.rs @ 757:21b186be2590

Split the Rust version into multiple crates.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 05 Jan 2021 02:16:32 +0100
parents examples/dump_ecl.rs@4d91790cf8ab
children
line wrap: on
line diff
copy from examples/dump_ecl.rs
copy to formats/src/bin/dump_ecl.rs
--- a/examples/dump_ecl.rs
+++ b/formats/src/bin/dump_ecl.rs
@@ -1,10 +1,16 @@
-use touhou::th06::ecl::{Ecl, CallMain, CallSub, Rank};
+use touhou_formats::th06::ecl::{Ecl, CallMain, CallSub, Rank};
 use std::env;
 use std::path::Path;
+use std::fs::File;
+use std::io::{self, BufReader, Read};
 
-#[path = "common.rs"]
-mod common;
-use common::{load_file_into_vec};
+pub fn load_file_into_vec<P: AsRef<Path>>(filename: P) -> io::Result<Vec<u8>> {
+    let file = File::open(filename)?;
+    let mut file = BufReader::new(file);
+    let mut buf = Vec::new();
+    file.read_to_end(&mut buf)?;
+    Ok(buf)
+}
 
 fn format_rank(rank: &Rank) -> String {
     format!("{}{}{}{}", if rank.contains(Rank::EASY) { 'E' } else { ' ' },