diff options
| -rw-r--r-- | crates/runrom/src/main.rs | 5 | ||||
| -rw-r--r-- | lib/vnf/src/lib.rs | 8 | ||||
| -rw-r--r-- | tests/vnf-tests/src/main.rs | 4 |
3 files changed, 10 insertions, 7 deletions
diff --git a/crates/runrom/src/main.rs b/crates/runrom/src/main.rs index 3a18946..4388766 100644 --- a/crates/runrom/src/main.rs +++ b/crates/runrom/src/main.rs @@ -255,7 +255,7 @@ fn start_from_reset_vector(file: &String) -> u16 { } fn run( - file: &String, + file: &Path, start: u16, end: u16, assume_function: bool, @@ -295,9 +295,10 @@ fn main() { Some(s) => s, None => start_from_reset_vector(&args.file), }; + let file = PathBuf::from(args.file.clone()); match run( - &args.file, + &file, start, args.until_address, args.assume_function, diff --git a/lib/vnf/src/lib.rs b/lib/vnf/src/lib.rs index e9c7539..b4e2399 100644 --- a/lib/vnf/src/lib.rs +++ b/lib/vnf/src/lib.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; use std::fs::File; use std::io::{ErrorKind, Read}; use std::ops::Range; +use std::path::Path; use xixanta::opcodes::AddressingMode; use xixanta::opcodes::{Instruction, InstructionIdentifier, OPCODES}; @@ -337,9 +338,12 @@ impl Machine { /// Initialize a Machine object by reading the ROM file located at /// 'file'. The machine should be initialized to start from the 'start' /// address, and the memory should be initialized with the given 'policy'. - pub fn from(file: &String, start: u16, policy: MemoryPolicy) -> Result<Self, String> { + pub fn from(file: &Path, start: u16, policy: MemoryPolicy) -> Result<Self, String> { let Ok(mut input) = File::open(file) else { - return Err(format!("failed to open the given file '{}'", file)); + return Err(format!( + "failed to open the given file '{}'", + file.display() + )); }; // Read the header in order to detect the PRG ROM size. diff --git a/tests/vnf-tests/src/main.rs b/tests/vnf-tests/src/main.rs index 6c62dbd..58a19af 100644 --- a/tests/vnf-tests/src/main.rs +++ b/tests/vnf-tests/src/main.rs @@ -53,9 +53,7 @@ fn parse_arguments() -> Args { fn run_break_mark_test(path: &String) -> Result<(), String> { let rom = PathBuf::from(path).join("out/stack.nes"); - let roms: String = rom.to_string_lossy().into_owned().to_string(); - - let mut machine = Machine::from(&roms, 0x8000, MemoryPolicy::default())?; + let mut machine = Machine::from(&rom, 0x8000, MemoryPolicy::default())?; // Get out of <start> let _ = machine.next_iteration(); |
