X-Git-Url: https://git.saurik.com/android/aapt.git/blobdiff_plain/dadd9c1fc18bd05c84a357b56e945b5829b3bd95..3c80e5c0dc993f14ed11bca00e023ce8c073a7f4:/Package.cpp diff --git a/Package.cpp b/Package.cpp index 23f641a..0df4606 100644 --- a/Package.cpp +++ b/Package.cpp @@ -34,7 +34,7 @@ ssize_t processAssets(Bundle* bundle, ZipFile* zip, const sp& dir, const AaptGroupEntry& ge); bool processFile(Bundle* bundle, ZipFile* zip, const sp& group, const sp& file); -bool okayToCompress(const String8& pathName); +bool okayToCompress(Bundle* bundle, const String8& pathName); ssize_t processJarFiles(Bundle* bundle, ZipFile* zip); /* @@ -327,7 +327,7 @@ bool processFile(Bundle* bundle, ZipFile* zip, } else if (!hasData) { /* don't compress certain files, e.g. PNGs */ int compressionMethod = bundle->getCompressionMethod(); - if (!okayToCompress(storageName)) { + if (!okayToCompress(bundle, storageName)) { compressionMethod = ZipEntry::kCompressStored; } result = zip->add(file->getSourceFile().string(), storageName.string(), compressionMethod, @@ -365,7 +365,7 @@ bool processFile(Bundle* bundle, ZipFile* zip, * Determine whether or not we want to try to compress this file based * on the file extension. */ -bool okayToCompress(const String8& pathName) +bool okayToCompress(Bundle* bundle, const String8& pathName) { String8 ext = pathName.getPathExtension(); int i; @@ -378,6 +378,19 @@ bool okayToCompress(const String8& pathName) return false; } + const android::Vector& others(bundle->getNoCompressExtensions()); + for (i = 0; i < (int)others.size(); i++) { + const char* str = others[i]; + int pos = pathName.length() - strlen(str); + if (pos < 0) { + continue; + } + const char* path = pathName.string(); + if (strcasecmp(path + pos, str) == 0) { + return false; + } + } + return true; }