diff --git a/src/processor/memory/rom.rs b/src/processor/memory/rom.rs index 8b17750..87be623 100644 --- a/src/processor/memory/rom.rs +++ b/src/processor/memory/rom.rs @@ -1,7 +1,7 @@ use crate::processor::memory::Address; use std::{ fs::{File, OpenOptions}, - io::{Read, Write}, + io::{Read, Seek, SeekFrom, Write}, path::PathBuf, str::from_utf8_unchecked, }; @@ -36,11 +36,13 @@ impl MaybeBufferedSram { .create_new(true) .open(path) .unwrap(); + writer.set_len(length as u64).unwrap(); Some(writer) } } else { None }; + Self { buf, inner, @@ -66,6 +68,7 @@ impl MaybeBufferedSram { fn flush(&mut self) { if let Some(ref mut writer) = self.inner { + writer.seek(SeekFrom::Start(0)).unwrap(); writer.write_all(&self.buf).unwrap(); } }