WIP: zip stuff

This commit is contained in:
SpikeHD
2022-05-15 16:50:12 -07:00
parent 11ad0e4453
commit 75954e944b
7 changed files with 206 additions and 5 deletions

33
src-tauri/src/unzip.rs Normal file
View File

@@ -0,0 +1,33 @@
use zip;
use std::fs::File;
use std::io::Read;
#[tauri::command]
pub fn unzip(zipfile: &str, zippath: &str, destpath: &str) {
let mut f = match File::open(zipfile) {
Ok(f) => f,
Err(e) => {
println!("Failed to open zip file: {}", e);
return;
}
};
let mut reader = std::io::Cursor::new(&f);
let mut zip = match zip::ZipArchive::new(&f) {
Ok(zip) => zip,
Err(e) => {
println!("Could not open zip file: {}", e);
return;
}
};
for i in 0..zip.len()
{
let mut file = zip.by_index(i).unwrap();
println!("Filename: {}", file.name());
let first_byte = file.bytes().next().unwrap();
println!("{:?}", first_byte);
}
}