MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / processOverlayFile

Function processOverlayFile

tools/aapt/Package.cpp:560–623  ·  view source on GitHub ↗

* Process a regular file, adding it to the archive if appropriate. * * This function is intended for use when creating a cached overlay package. * Only xml and .9.png files are processed and added to the package. * * If we're in "update" mode, and the file already exists in the archive, * delete the existing entry before adding the new one. */

Source from the content-addressed store, hash-verified

558 * delete the existing entry before adding the new one.
559 */
560bool processOverlayFile(Bundle* bundle, ZipFile* zip,
561 const sp<AaptGroup>& group, const sp<AaptFile>& file)
562{
563 const bool hasData = file->hasData();
564
565 String8 storageName(group->getPath());
566 storageName.convertToResPath();
567 ZipEntry* entry;
568 bool fromGzip = false;
569 status_t result;
570
571 if (strcasecmp(storageName.getPathExtension().string(), ".gz") == 0) {
572 fromGzip = true;
573 storageName = storageName.getBasePath();
574 }
575
576 if (bundle->getUpdate()) {
577 entry = zip->getEntryByName(storageName.string());
578 if (entry != NULL) {
579 /* file already exists in archive; there can be only one */
580 if (entry->getMarked()) {
581 fprintf(stderr,
582 "ERROR: '%s' exists twice (check for with & w/o '.gz'?)\n",
583 file->getPrintableSource().string());
584 return false;
585 }
586 zip->remove(entry);
587 }
588 }
589
590 if (hasData) {
591 const char* name = storageName.string();
592 if (endsWith(name, ".9.png") || endsWith(name, ".xml") || endsWith(name, ".arsc")) {
593 if (endsWith(name, ".9.png")) {
594 preProcessImage(bundle, file);
595 }
596 result = zip->add(file->getData(), file->getSize(), storageName.string(),
597 file->getCompressionMethod(), &entry);
598 if (result == NO_ERROR) {
599 if (bundle->getVerbose()) {
600 printf(" '%s'%s", storageName.string(), fromGzip ? " (from .gz)" : "");
601 if (entry->getCompressionMethod() == ZipEntry::kCompressStored) {
602 printf(" (not compressed)\n");
603 } else {
604 printf(" (compressed %d%%)\n", calcPercent(entry->getUncompressedLen(),
605 entry->getCompressedLen()));
606 }
607 }
608 entry->setMarked(true);
609 } else {
610 if (result == ALREADY_EXISTS) {
611 fprintf(stderr, " Unable to add '%s': file already in archive (try '-u'?)\n",
612 file->getPrintableSource().string());
613 } else {
614 fprintf(stderr, " Unable to add '%s': Zip add failed\n",
615 file->getPrintableSource().string());
616 }
617 return false;

Callers 1

processAssetsFunction · 0.85

Calls 15

endsWithFunction · 0.85
preProcessImageFunction · 0.85
calcPercentFunction · 0.85
stringMethod · 0.80
getUpdateMethod · 0.80
getEntryByNameMethod · 0.80
getMarkedMethod · 0.80
getPrintableSourceMethod · 0.80
getVerboseMethod · 0.80
getUncompressedLenMethod · 0.80
getCompressedLenMethod · 0.80
setMarkedMethod · 0.80

Tested by

no test coverage detected