Refactor: add subdirectory-after-writing-parent option

This commit is contained in:
Chris Hennick 2023-05-14 18:41:49 -07:00
parent 51ce58751e
commit c31d85930b
No known key found for this signature in database
GPG key ID: 25653935CC8B6C74

View file

@ -13,6 +13,9 @@ pub enum BasicFileOperation {
options: zip_next::write::FileOptions,
},
WriteDirectory(zip_next::write::FileOptions),
WriteSubdirectory {
parent_dir: BasicFileOperation::WriteSubdirectory
},
WriteSymlinkWithTarget {
target: Box<PathBuf>,
options: zip_next::write::FileOptions,
@ -57,6 +60,10 @@ fn do_operation<T>(writer: &mut RefCell<zip_next::ZipWriter<T>>,
BasicFileOperation::WriteDirectory(options) => {
writer.borrow_mut().add_directory(name, options)?;
}
BasicFileOperation::WriteSubdirectory(parent_dir) => {
do_operation(writer, parent_dir)?;
writer.borrow_mut().add_directory(parent_dir.referenceable_name() + name, options)?;
}
BasicFileOperation::WriteSymlinkWithTarget {target, options} => {
writer.borrow_mut().add_symlink(name, target.to_string_lossy(), options)?;
}