fix saves
This commit is contained in:
parent
e3330a4df7
commit
e0979f5049
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue