Get rom path from cli args

This commit is contained in:
Joseph Ferano 2025-04-17 23:27:00 +08:00
parent 102c08569a
commit a1386a289f

View File

@ -4,8 +4,14 @@ use std::fs::File;
use std::io::Read;
fn main() {
let mut f = File::open("basic.bin").expect("File not found");
let metadata = fs::metadata("basic.bin").expect("Could not load metadata");
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
panic!("Please provide a path to the rom")
}
let rom_path = &args[1];
let mut f = File::open(rom_path).expect("File not found");
let metadata = fs::metadata(rom_path).expect("Could not load metadata");
let bytes = metadata.len();
let mut buffer = vec![0; bytes as usize];
let bytes_read = f.read(&mut buffer).expect("Problem reading file into buffer");