diff options
author | 2023-08-10 23:54:44 +0000 | |
---|---|---|
committer | 2023-08-18 16:53:34 +0000 | |
commit | d2a698351d13901b95f836df09e9463344f6ab0e (patch) | |
tree | f5b5141eb4645a5ef124309dc814c6985bbed93f /tools/aapt/Package.cpp | |
parent | d122f435d437c0096466d008f1c460a62884be66 (diff) |
Use String8/16 c_str [tools]
Bug: 295394788
Test: make checkbuild
Change-Id: I82d6899d8c15a10b15399c39177290012bb5f13b
Merged-In: I82d6899d8c15a10b15399c39177290012bb5f13b
Diffstat (limited to 'tools/aapt/Package.cpp')
-rw-r--r-- | tools/aapt/Package.cpp | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/tools/aapt/Package.cpp b/tools/aapt/Package.cpp index f06643dcf784..965655b59a94 100644 --- a/tools/aapt/Package.cpp +++ b/tools/aapt/Package.cpp @@ -69,39 +69,39 @@ status_t writeAPK(Bundle* bundle, const String8& outputFile, const sp<OutputSet> * If "update" is set, update the contents of the existing archive. * Else, if "force" is set, remove the existing archive. */ - FileType fileType = getFileType(outputFile.string()); + FileType fileType = getFileType(outputFile.c_str()); if (fileType == kFileTypeNonexistent) { // okay, create it below } else if (fileType == kFileTypeRegular) { if (bundle->getUpdate()) { // okay, open it below } else if (bundle->getForce()) { - if (unlink(outputFile.string()) != 0) { - fprintf(stderr, "ERROR: unable to remove '%s': %s\n", outputFile.string(), + if (unlink(outputFile.c_str()) != 0) { + fprintf(stderr, "ERROR: unable to remove '%s': %s\n", outputFile.c_str(), strerror(errno)); goto bail; } } else { fprintf(stderr, "ERROR: '%s' exists (use '-f' to force overwrite)\n", - outputFile.string()); + outputFile.c_str()); goto bail; } } else { - fprintf(stderr, "ERROR: '%s' exists and is not a regular file\n", outputFile.string()); + fprintf(stderr, "ERROR: '%s' exists and is not a regular file\n", outputFile.c_str()); goto bail; } if (bundle->getVerbose()) { printf("%s '%s'\n", (fileType == kFileTypeNonexistent) ? "Creating" : "Opening", - outputFile.string()); + outputFile.c_str()); } status_t status; zip = new ZipFile; - status = zip->open(outputFile.string(), ZipFile::kOpenReadWrite | ZipFile::kOpenCreate); + status = zip->open(outputFile.c_str(), ZipFile::kOpenReadWrite | ZipFile::kOpenCreate); if (status != NO_ERROR) { fprintf(stderr, "ERROR: unable to open '%s' as Zip file for writing\n", - outputFile.string()); + outputFile.c_str()); goto bail; } @@ -112,7 +112,7 @@ status_t writeAPK(Bundle* bundle, const String8& outputFile, const sp<OutputSet> count = processAssets(bundle, zip, outputSet); if (count < 0) { fprintf(stderr, "ERROR: unable to process assets while packaging '%s'\n", - outputFile.string()); + outputFile.c_str()); result = count; goto bail; } @@ -124,7 +124,7 @@ status_t writeAPK(Bundle* bundle, const String8& outputFile, const sp<OutputSet> count = processJarFiles(bundle, zip); if (count < 0) { fprintf(stderr, "ERROR: unable to process jar files while packaging '%s'\n", - outputFile.string()); + outputFile.c_str()); result = count; goto bail; } @@ -169,12 +169,12 @@ status_t writeAPK(Bundle* bundle, const String8& outputFile, const sp<OutputSet> /* anything here? */ if (zip->getNumEntries() == 0) { if (bundle->getVerbose()) { - printf("Archive is empty -- removing %s\n", outputFile.getPathLeaf().string()); + printf("Archive is empty -- removing %s\n", outputFile.getPathLeaf().c_str()); } delete zip; // close the file so we can remove it in Win32 zip = NULL; - if (unlink(outputFile.string()) != 0) { - fprintf(stderr, "warning: could not unlink '%s'\n", outputFile.string()); + if (unlink(outputFile.c_str()) != 0) { + fprintf(stderr, "warning: could not unlink '%s'\n", outputFile.c_str()); } } @@ -187,9 +187,9 @@ status_t writeAPK(Bundle* bundle, const String8& outputFile, const sp<OutputSet> String8 dependencyFile = outputFile; dependencyFile.append(".d"); - FILE* fp = fopen(dependencyFile.string(), "a"); + FILE* fp = fopen(dependencyFile.c_str(), "a"); // Add this file to the dependency file - fprintf(fp, "%s \\\n", outputFile.string()); + fprintf(fp, "%s \\\n", outputFile.c_str()); fclose(fp); } @@ -199,10 +199,10 @@ bail: delete zip; // must close before remove in Win32 if (result != NO_ERROR) { if (bundle->getVerbose()) { - printf("Removing %s due to earlier failures\n", outputFile.string()); + printf("Removing %s due to earlier failures\n", outputFile.c_str()); } - if (unlink(outputFile.string()) != 0) { - fprintf(stderr, "warning: could not unlink '%s'\n", outputFile.string()); + if (unlink(outputFile.c_str()) != 0) { + fprintf(stderr, "warning: could not unlink '%s'\n", outputFile.c_str()); } } @@ -267,31 +267,31 @@ bool processFile(Bundle* bundle, ZipFile* zip, int fileNameLen = storageName.length(); int excludeExtensionLen = strlen(kExcludeExtension); if (fileNameLen > excludeExtensionLen - && (0 == strcmp(storageName.string() + (fileNameLen - excludeExtensionLen), + && (0 == strcmp(storageName.c_str() + (fileNameLen - excludeExtensionLen), kExcludeExtension))) { - fprintf(stderr, "warning: '%s' not added to Zip\n", storageName.string()); + fprintf(stderr, "warning: '%s' not added to Zip\n", storageName.c_str()); return true; } - if (strcasecmp(storageName.getPathExtension().string(), ".gz") == 0) { + if (strcasecmp(storageName.getPathExtension().c_str(), ".gz") == 0) { fromGzip = true; storageName = storageName.getBasePath(); } if (bundle->getUpdate()) { - entry = zip->getEntryByName(storageName.string()); + entry = zip->getEntryByName(storageName.c_str()); if (entry != NULL) { /* file already exists in archive; there can be only one */ if (entry->getMarked()) { fprintf(stderr, "ERROR: '%s' exists twice (check for with & w/o '.gz'?)\n", - file->getPrintableSource().string()); + file->getPrintableSource().c_str()); return false; } if (!hasData) { const String8& srcName = file->getSourceFile(); time_t fileModWhen; - fileModWhen = getFileModDate(srcName.string()); + fileModWhen = getFileModDate(srcName.c_str()); if (fileModWhen == (time_t) -1) { // file existence tested earlier, return false; // not expecting an error here } @@ -299,14 +299,14 @@ bool processFile(Bundle* bundle, ZipFile* zip, if (fileModWhen > entry->getModWhen()) { // mark as deleted so add() will succeed if (bundle->getVerbose()) { - printf(" (removing old '%s')\n", storageName.string()); + printf(" (removing old '%s')\n", storageName.c_str()); } zip->remove(entry); } else { // version in archive is newer if (bundle->getVerbose()) { - printf(" (not updating '%s')\n", storageName.string()); + printf(" (not updating '%s')\n", storageName.c_str()); } entry->setMarked(true); return true; @@ -321,22 +321,22 @@ bool processFile(Bundle* bundle, ZipFile* zip, //android_setMinPriority(NULL, ANDROID_LOG_VERBOSE); if (fromGzip) { - result = zip->addGzip(file->getSourceFile().string(), storageName.string(), &entry); + result = zip->addGzip(file->getSourceFile().c_str(), storageName.c_str(), &entry); } else if (!hasData) { /* don't compress certain files, e.g. PNGs */ int compressionMethod = bundle->getCompressionMethod(); if (!okayToCompress(bundle, storageName)) { compressionMethod = ZipEntry::kCompressStored; } - result = zip->add(file->getSourceFile().string(), storageName.string(), compressionMethod, + result = zip->add(file->getSourceFile().c_str(), storageName.c_str(), compressionMethod, &entry); } else { - result = zip->add(file->getData(), file->getSize(), storageName.string(), + result = zip->add(file->getData(), file->getSize(), storageName.c_str(), file->getCompressionMethod(), &entry); } if (result == NO_ERROR) { if (bundle->getVerbose()) { - printf(" '%s'%s", storageName.string(), fromGzip ? " (from .gz)" : ""); + printf(" '%s'%s", storageName.c_str(), fromGzip ? " (from .gz)" : ""); if (entry->getCompressionMethod() == ZipEntry::kCompressStored) { printf(" (not compressed)\n"); } else { @@ -348,10 +348,10 @@ bool processFile(Bundle* bundle, ZipFile* zip, } else { if (result == ALREADY_EXISTS) { fprintf(stderr, " Unable to add '%s': file already in archive (try '-u'?)\n", - file->getPrintableSource().string()); + file->getPrintableSource().c_str()); } else { fprintf(stderr, " Unable to add '%s': Zip add failed (%d)\n", - file->getPrintableSource().string(), result); + file->getPrintableSource().c_str(), result); } return false; } @@ -372,7 +372,7 @@ bool okayToCompress(Bundle* bundle, const String8& pathName) return true; for (i = 0; i < NELEM(kNoCompressExt); i++) { - if (strcasecmp(ext.string(), kNoCompressExt[i]) == 0) + if (strcasecmp(ext.c_str(), kNoCompressExt[i]) == 0) return false; } @@ -383,7 +383,7 @@ bool okayToCompress(Bundle* bundle, const String8& pathName) if (pos < 0) { continue; } - const char* path = pathName.string(); + const char* path = pathName.c_str(); if (strcasecmp(path + pos, str) == 0) { return false; } |