From 87999122da769e7979af32d4a9b5394969ead0bd Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Thu, 16 Jan 2020 19:49:43 +0200 Subject: [PATCH] feat/savestates: Add `write_bin_file` util function Former-commit-id: 88e12df1d8a88ad97756e943b4b959f73bb99c35 --- src/lib.rs | 2 +- src/util.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 3c2214a..307f0a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,6 +65,6 @@ pub mod prelude { pub use super::core::{GBAError, GBAResult, GameBoyAdvance}; #[cfg(feature = "debugger")] pub use super::debugger::Debugger; - pub use super::util::read_bin_file; + pub use super::util::{read_bin_file, write_bin_file}; pub use super::{AudioInterface, InputInterface, VideoInterface}; } diff --git a/src/util.rs b/src/util.rs index bc5732b..a7bd21a 100644 --- a/src/util.rs +++ b/src/util.rs @@ -11,6 +11,13 @@ pub fn read_bin_file(filename: &Path) -> io::Result> { Ok(buf) } +pub fn write_bin_file(filename: &Path, data: &Vec) -> io::Result<()> { + let mut f = File::create(filename)?; + f.write_all(data)?; + + Ok(()) +} + pub struct FpsCounter { count: u32, timer: time::Instant,