From 9dc569e646a9b9bfedebfecb3d683ef18e944370 Mon Sep 17 00:00:00 2001 From: mxve <68632137+mxve@users.noreply.github.com> Date: Tue, 29 Aug 2023 06:59:04 +0200 Subject: [PATCH] update io::unzip --- src/io.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/io.rs b/src/io.rs index d811760..f2f1f1b 100644 --- a/src/io.rs +++ b/src/io.rs @@ -1,11 +1,13 @@ -pub fn unzip(zip_path: &str, out_path: &str) { - let mut archive = zip::ZipArchive::new(fs::File::open(&temp_file).unwrap()).unwrap(); +use std::{fs, path::Path}; + +pub fn unzip(zip_path: &Path, out_path: &Path) { + let mut archive = zip::ZipArchive::new(fs::File::open(zip_path).unwrap()).unwrap(); for i in 0..archive.len() { let mut file = archive.by_index(i).unwrap(); - let outpath = iw4x_path.join(file.name()); + let outpath = out_path.join(file.name()); if (*file.name()).ends_with('/') { - fs::create_dir_all(&outpath).unwrap(); + fs::create_dir_all(outpath).unwrap(); } else { println!("Unpacking {}", file.name()); if let Some(p) = outpath.parent() {