diff options
author | Christopher Ferris <cferris@google.com> | 2015-11-10 14:55:12 -0800 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2016-01-14 12:30:20 -0800 |
commit | e6884ce56f07933d7292eb0ada1ff752f9c69e7a (patch) | |
tree | 33b4b8f67f2ff053660d936bfe4b116130004a6d /libziparchive/zip_archive.cc | |
parent | 047597b3fc345ee657ff1f00ad87521cf4ae455f (diff) | |
download | core-e6884ce56f07933d7292eb0ada1ff752f9c69e7a.tar.gz core-e6884ce56f07933d7292eb0ada1ff752f9c69e7a.tar.bz2 core-e6884ce56f07933d7292eb0ada1ff752f9c69e7a.zip |
Add a ZipArchiveStreamEntry class.
This allows someone to stream the data out of a zip archive
instead of extracting to a file or to memory.
Included in this change is a small cleanup of the makefile.
Change-Id: I8b679a679c3502ff4ea0bc4f9e918303657fa424
Diffstat (limited to 'libziparchive/zip_archive.cc')
-rw-r--r-- | libziparchive/zip_archive.cc | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc index 07ef6cd19..3b1e972ce 100644 --- a/libziparchive/zip_archive.cc +++ b/libziparchive/zip_archive.cc @@ -36,11 +36,12 @@ #include "log/log.h" #include "utils/Compat.h" #include "utils/FileMap.h" +#include "ziparchive/zip_archive.h" #include "zlib.h" #include "entry_name_utils-inl.h" #include "zip_archive_common.h" -#include "ziparchive/zip_archive.h" +#include "zip_archive_private.h" using android::base::get_unaligned; @@ -134,43 +135,6 @@ static const int32_t kErrorMessageLowerBound = -13; * every page that the Central Directory touches. Easier to tuck a copy * of the string length into the hash table entry. */ -struct ZipArchive { - /* open Zip archive */ - const int fd; - const bool close_file; - - /* mapped central directory area */ - off64_t directory_offset; - android::FileMap directory_map; - - /* number of entries in the Zip archive */ - uint16_t num_entries; - - /* - * We know how many entries are in the Zip archive, so we can have a - * fixed-size hash table. We define a load factor of 0.75 and overallocat - * so the maximum number entries can never be higher than - * ((4 * UINT16_MAX) / 3 + 1) which can safely fit into a uint32_t. - */ - uint32_t hash_table_size; - ZipString* hash_table; - - ZipArchive(const int fd, bool assume_ownership) : - fd(fd), - close_file(assume_ownership), - directory_offset(0), - num_entries(0), - hash_table_size(0), - hash_table(NULL) {} - - ~ZipArchive() { - if (close_file && fd >= 0) { - close(fd); - } - - free(hash_table); - } -}; /* * Round up to the next highest power of 2. |