mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 08:04:52 +01:00
WIP: zip stuff
This commit is contained in:
@@ -6,6 +6,7 @@ windows_subsystem = "windows"
|
||||
use open;
|
||||
use structs::{APIQuery};
|
||||
|
||||
mod unzip;
|
||||
mod downloader;
|
||||
mod lang;
|
||||
mod proxy;
|
||||
@@ -19,6 +20,7 @@ fn main() {
|
||||
disconnect,
|
||||
run_program,
|
||||
run_jar,
|
||||
unzip::unzip,
|
||||
open_in_browser,
|
||||
req_get,
|
||||
get_bg_file,
|
||||
|
||||
33
src-tauri/src/unzip.rs
Normal file
33
src-tauri/src/unzip.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user