use refcell
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
fs::File,
|
||||
path::Path,
|
||||
io::{
|
||||
@@ -44,18 +45,22 @@ pub fn zip_file(target: &str, zip_file: &str) -> XResult<()> {
|
||||
copy_io_with_head(&mut File::open(target_path)?, &mut zip, -1, "Compressing")?;
|
||||
} else {
|
||||
// TODO dir
|
||||
let mut_zip = RefCell::new(zip);
|
||||
walk_dir(&target_path, &|p, e| {
|
||||
print_message(MessageType::WARN, &format!("Compress {} failed: {}", &p.display(), &e));
|
||||
}, &|_f| {
|
||||
let _options = FileOptions::default().compression_method(CompressionMethod::Stored);
|
||||
// match zip.start_file("", options) {
|
||||
// Ok(_) => (),
|
||||
// Err(e) => print_message(MessageType::WARN, &format!("Compress {} failed: {}", &f.display(), &e)),
|
||||
// }
|
||||
}, &|f| {
|
||||
let options = FileOptions::default().compression_method(CompressionMethod::Stored);
|
||||
let mut m_zip = mut_zip.borrow_mut();
|
||||
match m_zip.start_file("", options) {
|
||||
Ok(_) => (),
|
||||
Err(e) => print_message(MessageType::WARN, &format!("Compress {} failed: {}", &f.display(), &e)),
|
||||
};
|
||||
// mut_zip.replace(m_zip);
|
||||
}, &|_| { true })?;
|
||||
}
|
||||
|
||||
zip.finish()?;
|
||||
// TODO finish
|
||||
// zip.finish()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user