aboutsummaryrefslogtreecommitdiff
path: root/src/binfile.rs
diff options
context:
space:
mode:
authorcc <cc@localhost>2025-08-20 22:14:13 -0700
committercc <cc@localhost>2025-08-20 22:19:01 -0700
commit15df0fec1e368599487e1faeaf8ecebd87980781 (patch)
tree94c9aba0cf1ba340e77b0c773e6869035ad9c8aa /src/binfile.rs
Initial commit
Diffstat (limited to 'src/binfile.rs')
-rw-r--r--src/binfile.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/binfile.rs b/src/binfile.rs
new file mode 100644
index 0000000..5b0b783
--- /dev/null
+++ b/src/binfile.rs
@@ -0,0 +1,27 @@
+use std::io::{Error,ErrorKind};
+
+pub fn dump_u32_vec(file_name: &str, data: Vec<u32>) -> Result<(), Error> {
+ use std::fs::File;
+ use std::io::Write;
+ if let Ok(mut file) = File::create(file_name) {
+ for value in data {
+ file.write_all(&value.to_le_bytes())?;
+ }
+ } else {
+ return Err(Error::new(ErrorKind::Other, "Error creating file"));
+ }
+ Ok(())
+}
+
+pub fn dump_u16_vec(file_name: &str, data: Vec<u16>) -> Result<(), Error> {
+ use std::fs::File;
+ use std::io::Write;
+ if let Ok(mut file) = File::create(file_name) {
+ for value in data {
+ file.write_all(&value.to_le_bytes())?;
+ }
+ } else {
+ return Err(Error::new(ErrorKind::Other, "Error creating file"));
+ }
+ Ok(())
+}