diff options
Diffstat (limited to 'cmds/idmap/scan.cpp')
-rw-r--r-- | cmds/idmap/scan.cpp | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp index 1153f38..84158d3 100644 --- a/cmds/idmap/scan.cpp +++ b/cmds/idmap/scan.cpp @@ -1,3 +1,6 @@ +#include <dirent.h> +#include <sys/stat.h> + #include "idmap.h" #include <UniquePtr.h> @@ -9,8 +12,6 @@ #include <utils/String16.h> #include <utils/String8.h> -#include <dirent.h> - #define NO_OVERLAY_TAG (-1000) using namespace android; @@ -64,30 +65,6 @@ namespace { return String8(tmp); } - int mkdir_p(const String8& path, uid_t uid, gid_t gid) - { - static const mode_t mode = - S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH; - struct stat st; - - if (stat(path.string(), &st) == 0) { - return 0; - } - if (mkdir_p(path.getPathDir(), uid, gid) < 0) { - return -1; - } - if (mkdir(path.string(), 0755) != 0) { - return -1; - } - if (chown(path.string(), uid, gid) == -1) { - return -1; - } - if (chmod(path.string(), mode) == -1) { - return -1; - } - return 0; - } - int parse_overlay_tag(const ResXMLTree& parser, const char *target_package_name) { const size_t N = parser.getAttributeCount(); @@ -97,8 +74,8 @@ namespace { size_t len; String16 key(parser.getAttributeName(i, &len)); if (key == String16("targetPackage")) { - const uint16_t *p = parser.getAttributeStringValue(i, &len); - if (p) { + const char16_t *p = parser.getAttributeStringValue(i, &len); + if (p != NULL) { target = String16(p, len); } } else if (key == String16("priority")) { @@ -164,27 +141,27 @@ namespace { return -1; } FileMap *dataMap = zip->createEntryFileMap(entry); - if (!dataMap) { + if (dataMap == NULL) { ALOGW("%s: failed to create FileMap\n", __FUNCTION__); return -1; } char *buf = new char[uncompLen]; if (NULL == buf) { - ALOGW("%s: failed to allocate %d byte\n", __FUNCTION__, uncompLen); - dataMap->release(); + ALOGW("%s: failed to allocate %zd byte\n", __FUNCTION__, uncompLen); + delete dataMap; return -1; } StreamingZipInflater inflater(dataMap, uncompLen); if (inflater.read(buf, uncompLen) < 0) { - ALOGW("%s: failed to inflate %d byte\n", __FUNCTION__, uncompLen); + ALOGW("%s: failed to inflate %zd byte\n", __FUNCTION__, uncompLen); delete[] buf; - dataMap->release(); + delete dataMap; return -1; } int priority = parse_manifest(buf, uncompLen, target_package_name); delete[] buf; - dataMap->release(); + delete dataMap; return priority; } } |