added .deb extraction

This commit is contained in:
specCon18 2025-03-22 10:22:08 -04:00
parent 0ed105ba4a
commit 1a4e6ddb3f
5 changed files with 42 additions and 9 deletions

11
Cargo.lock generated
View file

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "adler"
@ -28,6 +28,12 @@ dependencies = [
"memchr",
]
[[package]]
name = "ar"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d67af77d68a931ecd5cbd8a3b5987d63a1d1d1278f7f6a60ae33db485cdebb69"
[[package]]
name = "autocfg"
version = "1.1.0"
@ -832,8 +838,9 @@ dependencies = [
[[package]]
name = "sk_extract"
version = "0.9.0"
version = "1.0.2"
dependencies = [
"ar",
"bzip2",
"data-encoding",
"flate2",

View file

@ -6,6 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ar = "0.9.0"
bzip2 = "0.4.4"
data-encoding = "2.4.0"
flate2 = "1.0.27"

View file

@ -3,6 +3,7 @@ use lzma::reader::LzmaReader;
use flate2::read::GzDecoder;
use bzip2::read::BzDecoder;
use unrar::Archive;
use ar;
/// Extracts files from a ZIP archive.
///
@ -366,3 +367,21 @@ pub fn extract_txz(input_path: &Path, output_directory: &Path) -> Result<(), io:
}
Ok(())
}
pub fn extract_deb(input_path: &Path,) -> Result<(),io::Error>{
let input_file =File::open(&input_path).unwrap();
// Read an archive from the file foo.a:
let mut archive = ar::Archive::new(&input_file);
// Iterate over all entries in the archive:
while let Some(entry_result) = archive.next_entry() {
let mut entry = entry_result.unwrap();
// Create a new file with the same name as the archive entry:
let mut file = File::create(
str::from_utf8(entry.header().identifier()).unwrap(),
).unwrap();
// The Entry object also acts as an io::Read, so we can easily copy the
// contents of the archive entry into the file:
io::copy(&mut entry, &mut file).unwrap();
}
Ok(())
}

View file

@ -14,7 +14,7 @@ use sk_extract::extractors::{
// extract_arj,
// extract_cab,
// extract_chm,
// extract_deb,
extract_deb,
// extract_dmg,
// extract_iso,
// extract_lzh,
@ -186,6 +186,17 @@ fn run() -> i32 {
return 1;
}
}
"deb" => {
let output_directory = Path::new("output_directory"); // Change this to your desired output directory
if let Err(err) = fs::create_dir_all(&output_directory) {
println!("Error creating output directory: {}", err);
return 1;
}
if let Err(err) = extract_deb(&fname) {
println!("Error extracting DEB: {}", err);
return 1;
}
}
/*
"arj" => {
@ -206,12 +217,7 @@ fn run() -> i32 {
return 1;
}
}
"deb" => {
if let Err(err) = extract_deb(&fname) {
println!("Error extracting DEB: {}", err);
return 1;
}
}
"dmg" => {
if let Err(err) = extract_dmg(&fname) {
println!("Error extracting DMG: {}", err);

Binary file not shown.