mirror of
https://github.com/gopher64/gopher64.git
synced 2026-07-11 01:25:20 +02:00
7z support
This commit is contained in:
@@ -9,6 +9,7 @@ edition = "2021"
|
||||
dirs = "5.0"
|
||||
zip = "0.6"
|
||||
governor = "0.6"
|
||||
sevenz-rust = "0.5"
|
||||
sha2 = "0.10"
|
||||
sdl2-sys = { git = "https://github.com/Rust-SDL2/rust-sdl2.git" }
|
||||
|
||||
|
||||
+24
@@ -52,6 +52,30 @@ fn main() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if file_path.extension().unwrap().to_ascii_lowercase() == "7z" {
|
||||
let mut archive =
|
||||
sevenz_rust::SevenZReader::open(file_path, sevenz_rust::Password::empty()).unwrap();
|
||||
|
||||
let mut found = false;
|
||||
archive
|
||||
.for_each_entries(
|
||||
&mut |entry: &sevenz_rust::SevenZArchiveEntry, reader: &mut dyn std::io::Read| {
|
||||
let name = entry.name().to_ascii_lowercase();
|
||||
if !found
|
||||
&& (name.ends_with("z64") || name.ends_with("n64") || name.ends_with("v64"))
|
||||
{
|
||||
reader
|
||||
.read_to_end(&mut contents)
|
||||
.expect("could not read zip file");
|
||||
found = true;
|
||||
} else {
|
||||
//skip other files
|
||||
std::io::copy(reader, &mut std::io::sink())?;
|
||||
}
|
||||
Ok(true)
|
||||
},
|
||||
)
|
||||
.expect("ok");
|
||||
} else {
|
||||
contents = fs::read(file_path).expect("Should have been able to read the file");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user