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