diff --git a/Cargo.lock b/Cargo.lock index dcda099..7156181 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -323,7 +323,7 @@ dependencies = [ [[package]] name = "nicotine" -version = "0.1.6" +version = "0.1.7" dependencies = [ "walkdir", "zip", diff --git a/Cargo.toml b/Cargo.toml index 3321083..6a9453b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nicotine" -version = "0.1.6" +version = "0.1.7" edition = "2024" description = "A small rust crate for patching mojang's Authlib" authors = ["alterwain"] @@ -10,5 +10,5 @@ crate-type = ["staticlib", "cdylib", "lib"] [dependencies] zip-extract = "0.2.1" -zip = "2.2.3" +zip = { version = "2.2.3", features = ["deflate"] } walkdir = "2" \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index addf1a6..8a8b4cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,8 +74,14 @@ fn zip_dir( writer: T, ) -> zip::result::ZipResult<()> { let mut zip = ZipWriter::new(writer); - let options = SimpleFileOptions::default() - .compression_method(CompressionMethod::Stored); + + let file_options = SimpleFileOptions::default() + .compression_method(CompressionMethod::Deflated) + .unix_permissions(0o644); // Simulating a DOS file attribute + + let dir_options = SimpleFileOptions::default() + .compression_method(CompressionMethod::Deflated) + .unix_permissions(0o755); let mut buffer = Vec::new(); @@ -83,15 +89,16 @@ fn zip_dir( let entry = entry.unwrap(); let path = entry.path(); let name = path.strip_prefix(prefix).unwrap(); + let dos_path = name.to_string_lossy().replace("/", "\\"); if path.is_file() { let mut f = File::open(path)?; f.read_to_end(&mut buffer)?; - zip.start_file(name.to_string_lossy(), options)?; + zip.start_file(dos_path, file_options)?; zip.write_all(&buffer)?; buffer.clear(); } else if path.is_dir() { - zip.add_directory(name.to_string_lossy(), options)?; + zip.add_directory(dos_path, dir_options)?; } } zip.finish()?;