diff options
author | gennyble <gen@nyble.dev> | 2023-06-08 00:51:05 -0500 |
---|---|---|
committer | gennyble <gen@nyble.dev> | 2023-06-08 00:51:05 -0500 |
commit | f0ab93507bc7de8be6172768e19d6f9baa5e46e7 (patch) | |
tree | 45e82ae726c2d26b75a194113b7e45472f10e9eb /src | |
parent | 20a440b40b9c953b8fd807fa117a9816b1d106b6 (diff) | |
download | lri-rs-f0ab93507bc7de8be6172768e19d6f9baa5e46e7.tar.gz lri-rs-f0ab93507bc7de8be6172768e19d6f9baa5e46e7.zip |
notes 2
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 28f557a..1fdb23e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::{fs::File, path::Path}; +use std::{fs::File, io::Write, os::unix::prelude::FileExt, path::Path}; use lri_rs::Message; use png::{BitDepth, ColorType}; @@ -81,7 +81,40 @@ fn main() { } println!("\nDumping header info.."); - heads.iter().for_each(|h| h.header.nice_info()) + heads.iter().for_each(|h| h.header.print_info()); + + println!("\nWriting large ones to disk!"); + for (idx, head) in heads.iter().enumerate() { + if head.header.header_length > 1024 * 1024 { + // I guess we only care if it's at least a megabyte + let name = format!("{idx}.lri_part"); + let mut file = File::create(&name).unwrap(); + file.write_all(&data[head.start..head.end]).unwrap(); + println!( + "Wrote {:.2}MB to disk as {name}", + head.header.combined_length as f32 / (1024.0 * 1024.0) + ); + } + + if idx == 2 { + let data = &data[head.start + 32..head.end]; + + let mut first = vec![0; data.len() / 2]; + let mut second = vec![0; data.len() / 2]; + for (idx, chnk) in data.chunks(2).enumerate() { + first[idx] = chnk[0]; + second[idx] = chnk[0]; + } + + let name = format!("{idx}_first.lri_part"); + let mut file = File::create(&name).unwrap(); + file.write_all(&first).unwrap(); + + let name = format!("{idx}_second.lri_part"); + let mut file = File::create(&name).unwrap(); + file.write_all(&second).unwrap(); + } + } } fn make_png<P: AsRef<Path>>( |