diff options
author | cc <cc@localhost> | 2025-08-20 18:59:47 -0700 |
---|---|---|
committer | cc <cc@localhost> | 2025-08-20 18:59:59 -0700 |
commit | b0ff49fdd4ae82af5cf89180078ea7314072c29f (patch) | |
tree | 0287a8cf3f04f7a040578a4e14ec446a47b6c4a7 /src/binfile.rs | |
parent | 27d77b602e2d43a8bab413d69b86c38e53435a8e (diff) |
Add binary file output function
Diffstat (limited to 'src/binfile.rs')
-rw-r--r-- | src/binfile.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/binfile.rs b/src/binfile.rs new file mode 100644 index 0000000..9b50a70 --- /dev/null +++ b/src/binfile.rs @@ -0,0 +1,14 @@ +pub fn dump_u32_vec(file_name: &str, data: Vec<u32>) -> Result<(), String> { + use std::fs::File; + use std::io::Write; + if let Ok(mut file) = File::create(file_name) { + for value in data { + if let Err(error) = file.write_all(&value.to_le_bytes()) { + return Err(error.to_string()); + } + } + } else { + return Err(String::from("Error creating file")); + } + Ok(()) +} |