Add 7z support

This commit is contained in:
Thoronium
2023-04-07 13:10:00 -06:00
parent 68f0cce154
commit 096992572c
3 changed files with 214 additions and 28 deletions

View File

@@ -72,6 +72,10 @@ pub fn unzip(
let archive = Archive::new(zipfile.clone());
name = archive.list().unwrap().next().unwrap().unwrap().filename;
} else if zipfile.ends_with(".7z") {
success = extract_7z(&zipfile, &f, &full_path, top_level.unwrap_or(true));
name = String::from("banana");
} else {
success = extract_zip(&zipfile, &f, &full_path, top_level.unwrap_or(true));
@@ -103,7 +107,7 @@ pub fn unzip(
.unwrap();
}
if zipfile.contains("3dmigoto") {
if zipfile.contains("GIMI") {
window
.emit("migoto_extracted", destpath.to_string() + "3DMigoto Loader.exe")
.unwrap();
@@ -175,3 +179,20 @@ fn extract_zip(_zipfile: &str, f: &File, full_path: &path::Path, top_level: bool
}
}
}
fn extract_7z(sevenzfile: &str, _f: &File, full_path: &path::Path, _top_level: bool) -> bool {
match sevenz_rust::decompress_file(sevenzfile, full_path) {
Ok(_) => {
println!(
"Extracted 7zip file to: {}",
full_path.to_str().unwrap_or("Error")
);
true
}
Err(e) => {
println!("Failed to extract 7zip file: {}", e);
false
}
}
}