mirror of
https://github.com/Ap0dexMe0/unixtract.git
synced 2026-07-16 05:04:22 +02:00
+ cleanup
This commit is contained in:
@@ -9,6 +9,7 @@ use binrw::BinReaderExt;
|
||||
|
||||
use crate::utils::common;
|
||||
use include::*;
|
||||
use log::info;
|
||||
|
||||
pub fn is_epk1_file(app_ctx: &AppContext) -> Result<Option<Box<dyn Any>>, Box<dyn std::error::Error>> {
|
||||
let file = match app_ctx.file() {Some(f) => f, None => return Ok(None)};
|
||||
@@ -30,10 +31,10 @@ pub fn extract_epk1(app_ctx: &AppContext, _ctx: Box<dyn Any>) -> Result<(), Box<
|
||||
let init_pak_count = u32::from_le_bytes(init_pak_count_bytes.try_into().unwrap());
|
||||
|
||||
if init_pak_count > 256 {
|
||||
println!("\nBig endian EPK1 detected.");
|
||||
info!("\nBig endian EPK1 detected.");
|
||||
epk1_type = Epk1Type::BigEndian;
|
||||
} else if init_pak_count < 33 {
|
||||
println!("\nLittle endian EPK1 detected.");
|
||||
info!("\nLittle endian EPK1 detected.");
|
||||
epk1_type = Epk1Type::LittleEndian;
|
||||
} else {
|
||||
return Err("Unknown EPK1 variant!".into());
|
||||
@@ -60,7 +61,7 @@ pub fn extract_epk1(app_ctx: &AppContext, _ctx: Box<dyn Any>) -> Result<(), Box<
|
||||
|
||||
let version = common::read_exact(&mut file, 4)?;
|
||||
|
||||
println!("EPK info -\nData size: {}\nPak count: {}\nVersion: {:02x?}.{:02x?}.{:02x?}",
|
||||
info!("EPK info -\nData size: {}\nPak count: {}\nVersion: {:02x?}.{:02x?}.{:02x?}",
|
||||
header.file_size, header.pak_count, version[1], version[2], version[3]);
|
||||
|
||||
} else if epk1_type == Epk1Type::LittleEndian {
|
||||
@@ -91,7 +92,7 @@ pub fn extract_epk1(app_ctx: &AppContext, _ctx: Box<dyn Any>) -> Result<(), Box<
|
||||
let ota_id_bytes = common::read_exact(&mut file, 32)?;
|
||||
let ota_id = common::string_from_bytes(&ota_id_bytes);
|
||||
|
||||
println!("EPK info -\nData size: {}\nHeader size: {}\nPak count: {}\nOTA ID: {}\nVersion: {:02x?}.{:02x?}.{:02x?}",
|
||||
info!("EPK info -\nData size: {}\nHeader size: {}\nPak count: {}\nOTA ID: {}\nVersion: {:02x?}.{:02x?}.{:02x?}",
|
||||
header.file_size, header_size, header.pak_count, ota_id, version[2], version[1], version[0]);
|
||||
}
|
||||
|
||||
@@ -99,7 +100,7 @@ pub fn extract_epk1(app_ctx: &AppContext, _ctx: Box<dyn Any>) -> Result<(), Box<
|
||||
file.seek(SeekFrom::Start(pak.offset as u64))?;
|
||||
let pak_header: PakHeader = if epk1_type == Epk1Type::BigEndian {file.read_be()?} else {file.read_le()?};
|
||||
|
||||
println!("\n({}/{}) - {}, Offset: {}, Size: {}, Platform: {}",
|
||||
info!("\n({}/{}) - {}, Offset: {}, Size: {}, Platform: {}",
|
||||
i + 1, paks.len(), pak_header.pak_name(), pak.offset, pak_header.image_size, pak_header.platform_id());
|
||||
|
||||
let data = common::read_exact(&mut file, pak_header.image_size as usize)?;
|
||||
@@ -109,7 +110,7 @@ pub fn extract_epk1(app_ctx: &AppContext, _ctx: Box<dyn Any>) -> Result<(), Box<
|
||||
let mut out_file = OpenOptions::new().write(true).create(true).open(output_path)?;
|
||||
out_file.write_all(&data)?;
|
||||
|
||||
println!("- Saved file!");
|
||||
info!("- Saved file!");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user