From e0979f50491b315ac08ab2543e6fc50d547b42f3 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Thu, 2 Mar 2023 18:30:44 +1100 Subject: [PATCH] fix saves --- src/processor/memory/rom.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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(); } }