use io::copy instead of read_to_end

This commit is contained in:
Adrian 2024-04-15 10:34:49 +02:00
parent 42a954206d
commit f6a34093fc
No known key found for this signature in database
GPG key ID: DD5B34F6F180D815

View file

@ -45,17 +45,13 @@ fn real_main() -> i32 {
let mut files: Vec<PathBuf> = vec![]; let mut files: Vec<PathBuf> = vec![];
gather_files(to_append.as_ref(), &mut files); gather_files(to_append.as_ref(), &mut files);
let mut buf: Vec<u8> = vec![];
for file in files { for file in files {
append_zip append_zip
.start_file(file.to_string_lossy(), Default::default()) .start_file(file.to_string_lossy(), Default::default())
.unwrap(); .unwrap();
let mut f = File::open(file).unwrap(); let mut f = File::open(file).unwrap();
f.read_to_end(&mut buf).unwrap(); let _ = std::io::copy(&mut f, &mut append_zip);
append_zip.write_all(&buf).unwrap();
buf.clear();
} }
append_zip.finish().unwrap(); append_zip.finish().unwrap();