mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
Allow empty dirs on zip
This commit is contained in:
parent
d43a93d8bb
commit
0c65fbd2d4
@ -88,14 +88,16 @@ where
|
|||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
|
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
continue;
|
if dir_is_empty(path)? {
|
||||||
|
writer.add_directory(path.to_str().unwrap().to_owned(), options)?;
|
||||||
|
}
|
||||||
|
// If a dir has files, the files are responsible for creating them.
|
||||||
|
} else {
|
||||||
|
writer.start_file(path.to_str().unwrap().to_owned(), options)?;
|
||||||
|
// TODO: better error messages
|
||||||
|
let file_bytes = fs::read(entry.path())?;
|
||||||
|
writer.write_all(&*file_bytes)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.start_file(path.to_str().unwrap().to_owned(), options)?;
|
|
||||||
|
|
||||||
// TODO: better error messages
|
|
||||||
let file_bytes = fs::read(entry.path())?;
|
|
||||||
writer.write_all(&*file_bytes)?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
env::set_current_dir(previous_location)?;
|
env::set_current_dir(previous_location)?;
|
||||||
@ -112,6 +114,10 @@ fn check_for_comments(file: &ZipFile) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dir_is_empty(dir_path: &Path) -> crate::Result<bool> {
|
||||||
|
Ok(dir_path.read_dir()?.next().is_none())
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn __unix_set_permissions(file_path: &Path, file: &ZipFile) -> crate::Result<()> {
|
fn __unix_set_permissions(file_path: &Path, file: &ZipFile) -> crate::Result<()> {
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user