I do not understand how this library works and the documentation is one of the worst I've ever seen. How can I read text files stored inside the archive into memory? Am I even using the right functions?
// Reading the raw zip file into memory
std::ifstream raw_file("archive.zip", std::ios::binary);
auto buffer = static_cast<std::ostringstream&>(
std::ostringstream{} << raw_file.rdbuf())
.str();
struct archive* a = archive_read_new();
struct archive_entry* entry;
archive_read_support_compression_all(a);
archive_read_support_format_raw(a);
int r =
archive_read_open_memory(a, buffer.data(), buffer.size());
while (archive_read_next_header(a, &entry) == ARCHIVE_OK) {
archive_read_data(a, buffer.data(), buffer.size());
}
// This prints out binary data instead of text files stored inside the archive
std::cout << buffer << std::endl;
r = archive_read_free(a);