mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-16 17:14:36 +01:00
Add 7z support
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user