-
Notifications
You must be signed in to change notification settings - Fork 204
Conversation
Great work! I would really looking forward to it accepting this SPECIFIC pullrequest since I need it for my work |
bump |
I would suggest just naming the function |
bump |
src/read.rs
Outdated
@@ -209,7 +209,7 @@ fn make_reader<'a>( | |||
impl<R: Read + io::Seek> ZipArchive<R> { | |||
/// Get the directory start offset and number of files. This is done in a | |||
/// separate function to ease the control flow design. | |||
fn get_directory_counts( | |||
pub fn get_directory_counts( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub(crate)
will do the trick!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's nice. BTW, I saw in another PR that you mention about the current situation of having various edge-case API sprinkled around, and I really appreciate your works in #156 in your limited time. I'll see if I can help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the look of this! I'll need to test a couple things soon, but there shouldn't be any problem :)
src/write.rs
Outdated
} | ||
|
||
for _ in 0..number_of_files { | ||
let file = central_header_to_zip_file(&mut readwriter, archive_offset)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use an iterator here. Roughly
let files = (..number_of_files)
.map(|_| central_header_to_zip_file(&mut readwriter, archiveoffset))
.collect::<Result<Vec<_>, _>>()?;
used internally by the appendable ZipWriter
Thanks for your suggestions @Plecra! I learn something useful. |
3def6bc
to
cfa3b11
Compare
Thanks for the new API @Contextualist ! This looks great ~ |
The implementation provides an alternative constructor,
new_append
, forZipWriter
, that takes a read-write buffer of existing archive and make it possible to add files to it.new_append
is mostly a copy of theZipArchive
constructor. It parses the central directory for the file list, and then set the cursor to the beginning of central directory in order to overwrite it. Users are expected to use theZipWriter
in the same way as if it is constructed from an empty buffer. Whenfinish
is called, the new central directory added will contains information for all prior files along with the appended files.As the central directory parsing is borrowed from
ZipArchive
's internal implementation, I need to makeZipArchive ::get_directory_counts
andcentral_header_to_zip_file
public, which looks awkward to me. Is there a more graceful way? Also, suggestions on a better name for the constructornew_append
are welcome.