general: move common to utils, move common compression function to utils, clean up inconsitencies + add missing header to sony_bdp

This commit is contained in:
theubusu
2025-11-26 17:29:25 +01:00
parent 82be46fbd6
commit b608888538
32 changed files with 92 additions and 111 deletions
+3 -11
View File
@@ -1,12 +1,11 @@
use std::str;
use std::path::{Path};
use std::io::{Read, Write};
use std::io::{Write};
use std::fs::{self, File, OpenOptions};
use binrw::{BinRead, BinReaderExt};
use flate2::read::GzDecoder;
use crate::common;
use crate::utils::common;
use crate::utils::compression::{decompress_gzip};
#[derive(Debug, BinRead)]
struct PIMG {
@@ -41,13 +40,6 @@ pub fn is_nvt_timg_file(file: &File) -> bool {
}
}
fn decompress_gzip(compressed_data: &[u8]) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
let mut decoder = GzDecoder::new(compressed_data);
let mut decompressed = Vec::new();
decoder.read_to_end(&mut decompressed)?;
Ok(decompressed)
}
pub fn extract_nvt_timg(mut file: &File, output_folder: &str) -> Result<(), Box<dyn std::error::Error>> {
let _timg = common::read_exact(&mut file, 288)?; //TIMG magic + header