added .deb extraction
This commit is contained in:
parent
0ed105ba4a
commit
1a4e6ddb3f
5 changed files with 42 additions and 9 deletions
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
|||
20
src/main.rs
20
src/main.rs
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue