summaryrefslogtreecommitdiff
path: root/libs/androidfw/ZipFileRO.cpp
diff options
context:
space:
mode:
author Dianne Hackborn <hackbod@google.com> 2017-10-31 19:55:42 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-10-31 19:55:42 +0000
commitad5570f58d40b7997afeba337f83dda4ae9a5476 (patch)
treeca1554d5bbe6466c6b0f3d0383c73bbed6515b78 /libs/androidfw/ZipFileRO.cpp
parent81c671da60a1d27407846039308642e71ab16c13 (diff)
parentca3872ce36c94090ae18519dc7fe0cf39d834c4a (diff)
Merge "Fully implement "install" and "install-write" in PackageManagerShellCommand."
Diffstat (limited to 'libs/androidfw/ZipFileRO.cpp')
-rw-r--r--libs/androidfw/ZipFileRO.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/libs/androidfw/ZipFileRO.cpp b/libs/androidfw/ZipFileRO.cpp
index 49fe8a261178..6e2ca60cc3d3 100644
--- a/libs/androidfw/ZipFileRO.cpp
+++ b/libs/androidfw/ZipFileRO.cpp
@@ -55,7 +55,9 @@ private:
ZipFileRO::~ZipFileRO() {
CloseArchive(mHandle);
- free(mFileName);
+ if (mFileName != NULL) {
+ free(mFileName);
+ }
}
/*
@@ -76,6 +78,20 @@ ZipFileRO::~ZipFileRO() {
}
+/* static */ ZipFileRO* ZipFileRO::openFd(int fd, const char* debugFileName,
+ bool assume_ownership)
+{
+ ZipArchiveHandle handle;
+ const int32_t error = OpenArchiveFd(fd, debugFileName, &handle, assume_ownership);
+ if (error) {
+ ALOGW("Error opening archive fd %d %s: %s", fd, debugFileName, ErrorCodeString(error));
+ CloseArchive(handle);
+ return NULL;
+ }
+
+ return new ZipFileRO(handle, strdup(debugFileName));
+}
+
ZipEntryRO ZipFileRO::findEntryByName(const char* entryName) const
{
_ZipEntryRO* data = new _ZipEntryRO;
@@ -139,7 +155,8 @@ bool ZipFileRO::startIteration(void** cookie, const char* prefix, const char* su
prefix ? &pe : NULL,
suffix ? &se : NULL);
if (error) {
- ALOGW("Could not start iteration over %s: %s", mFileName, ErrorCodeString(error));
+ ALOGW("Could not start iteration over %s: %s", mFileName != NULL ? mFileName : "<null>",
+ ErrorCodeString(error));
delete ze;
return false;
}
@@ -154,7 +171,8 @@ ZipEntryRO ZipFileRO::nextEntry(void* cookie)
int32_t error = Next(ze->cookie, &(ze->entry), &(ze->name));
if (error) {
if (error != -1) {
- ALOGW("Error iteration over %s: %s", mFileName, ErrorCodeString(error));
+ ALOGW("Error iteration over %s: %s", mFileName != NULL ? mFileName : "<null>",
+ ErrorCodeString(error));
}
return NULL;
}