summaryrefslogtreecommitdiff
path: root/include/ziparchive/zip_archive.h
diff options
context:
space:
mode:
authorPiotr Jastrzebski <haaawk@google.com>2014-08-11 16:35:11 +0100
committerPiotr Jastrzebski <haaawk@google.com>2014-08-15 12:39:45 +0100
commitecccc5ad9397264d3d05018647b4a2e39d7c774c (patch)
tree3df7aee455f71717f090ca986fc4e22cb89fc47f /include/ziparchive/zip_archive.h
parente1ba39aa6644feb9c5f742f65db6d3363203951f (diff)
Replace char* with ZipEntryName in ziparchive API.
It's important because entry names can be encoded in UTF-8 and can have \0 character in the middle. Use vector instead of char* for prefix in IterationHandle. Bug: 16162465 Change-Id: Ie34c8d7c6231cc258530c22bdde5542895213649
Diffstat (limited to 'include/ziparchive/zip_archive.h')
-rw-r--r--include/ziparchive/zip_archive.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/include/ziparchive/zip_archive.h b/include/ziparchive/zip_archive.h
index 27a97967d..7da6e849c 100644
--- a/include/ziparchive/zip_archive.h
+++ b/include/ziparchive/zip_archive.h
@@ -21,6 +21,7 @@
#define LIBZIPARCHIVE_ZIPARCHIVE_H_
#include <stdint.h>
+#include <string.h>
#include <sys/types.h>
#include <utils/Compat.h>
@@ -33,8 +34,16 @@ enum {
};
struct ZipEntryName {
- const char* name;
+ const uint8_t* name;
uint16_t name_length;
+
+ ZipEntryName() {}
+
+ /*
+ * entry_name has to be an c-style string with only ASCII characters.
+ */
+ explicit ZipEntryName(const char* entry_name)
+ : name(reinterpret_cast<const uint8_t*>(entry_name)), name_length(strlen(entry_name)) {}
};
/*
@@ -124,7 +133,7 @@ void CloseArchive(ZipArchiveHandle handle);
* and length, a call to VerifyCrcAndLengths must be made after entry data
* has been processed.
*/
-int32_t FindEntry(const ZipArchiveHandle handle, const char* entryName,
+int32_t FindEntry(const ZipArchiveHandle handle, const ZipEntryName& entryName,
ZipEntry* data);
/*
@@ -136,12 +145,12 @@ int32_t FindEntry(const ZipArchiveHandle handle, const char* entryName,
* EndIteration to free any allocated memory.
*
* This method also accepts an optional prefix to restrict iteration to
- * entry names that start with |prefix|.
+ * entry names that start with |optional_prefix|.
*
* Returns 0 on success and negative values on failure.
*/
int32_t StartIteration(ZipArchiveHandle handle, void** cookie_ptr,
- const char* prefix);
+ const ZipEntryName* optional_prefix);
/*
* Advance to the next element in the zipfile in iteration order.