I've been using Java's standard library for writing Zip Archive files and, in that case, I do not have to know the files that are going to be stored into a zip file beforehand: I would simply create a new ZipEntry and then write into the ZipFile stream.
On the other hand, LibArchive and ZLib for C++ have to set the to-be-archived file information beforehand: in my case the data that I want to compress comes from an extern stream, and hence I cannot query the size of the stream itself. Is there a library/way to use those libraries such that the initial file information is not required?
EDIT Moreover, the following C++ code with LibArchive produces a valid ZIP file containing a file with no data.
a = archive_write_new();
archive_write_add_filter_gzip(a);
archive_write_set_format_pax_restricted(a);
archive_write_open_filename(a, path.c_str());
entry = archive_entry_new(); // Note 2
archive_entry_set_pathname(entry, entryName.c_str());
archive_entry_set_perm(entry, 0666);
archive_write_header(a, entry);
size_t s = archive_write_data(a, buff, len);
archive_entry_free(entry);
archive_write_close(a);
archive_write_free(a);