本文整理汇总了C++中String8::getPathLeaf方法的典型用法代码示例。如果您正苦于以下问题:C++ String8::getPathLeaf方法的具体用法?C++ String8::getPathLeaf怎么用?C++ String8::getPathLeaf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String8
的用法示例。
在下文中一共展示了String8::getPathLeaf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeAPK
status_t writeAPK(Bundle* bundle, const String8& outputFile,
const sp<OutputSet>& outputSet, bool isOverlay)
{
#if BENCHMARK
fprintf(stdout, "BENCHMARK: Starting APK Bundling \n");
long startAPKTime = clock();
#endif /* BENCHMARK */
status_t result = NO_ERROR;
ZipFile* zip = NULL;
//bundle->setPackageCount(0);
/*
* Prep the Zip archive.
*
* If the file already exists, fail unless "update" or "force" is set.
* 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());
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(),
strerror(errno));
goto bail;
}
} else {
fprintf(stderr, "ERROR: '%s' exists (use '-f' to force overwrite)\n",
outputFile.string());
goto bail;
}
} else {
fprintf(stderr, "ERROR: '%s' exists and is not a regular file\n", outputFile.string());
goto bail;
}
if (bundle->getVerbose()) {
printf("%s '%s'\n", (fileType == kFileTypeNonexistent) ? "Creating" : "Opening",
outputFile.string());
}
status_t status;
zip = new ZipFile;
status = zip->open(outputFile.string(), ZipFile::kOpenReadWrite | ZipFile::kOpenCreate);
if (status != NO_ERROR) {
fprintf(stderr, "ERROR: unable to open '%s' as Zip file for writing\n",
outputFile.string());
goto bail;
}
result = writeAPK(bundle, zip, outputFile.string(), outputSet, isOverlay);
if (result != NO_ERROR) {
fprintf(stderr, "ERROR: Writing apk failed\n");
goto bail;
}
/* anything here? */
if (zip->getNumEntries() == 0) {
if (bundle->getVerbose()) {
printf("Archive is empty -- removing %s\n", outputFile.getPathLeaf().string());
}
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 we've been asked to generate a dependency file for the .ap_ package,
// do so here
if (bundle->getGenDependencies()) {
// The dependency file gets output to the same directory
// as the specified output file with an additional .d extension.
// e.g. bin/resources.ap_.d
String8 dependencyFile = outputFile;
dependencyFile.append(".d");
FILE* fp = fopen(dependencyFile.string(), "a");
// Add this file to the dependency file
fprintf(fp, "%s \\\n", outputFile.string());
fclose(fp);
}
assert(result == NO_ERROR);
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());
}
if (unlink(outputFile.string()) != 0) {
fprintf(stderr, "warning: could not unlink '%s'\n", outputFile.string());
//.........这里部分代码省略.........
示例2: writeAPK
//.........这里部分代码省略.........
goto bail;
}
if (bundle->getVerbose()) {
printf("Generated %d file%s\n", count, (count==1) ? "" : "s");
}
count = processJarFiles(bundle, zip);
if (count < 0) {
fprintf(stderr, "ERROR: unable to process jar files while packaging '%s'\n",
outputFile.string());
result = count;
goto bail;
}
if (bundle->getVerbose())
printf("Included %d file%s from jar/zip files.\n", count, (count==1) ? "" : "s");
result = NO_ERROR;
/*
* Check for cruft. We set the "marked" flag on all entries we created
* or decided not to update. If the entry isn't already slated for
* deletion, remove it now.
*/
{
if (bundle->getVerbose())
printf("Checking for deleted files\n");
int i, removed = 0;
for (i = 0; i < zip->getNumEntries(); i++) {
ZipEntry* entry = zip->getEntryByIndex(i);
if (!entry->getMarked() && entry->getDeleted()) {
if (bundle->getVerbose()) {
printf(" (removing crufty '%s')\n",
entry->getFileName());
}
zip->remove(entry);
removed++;
}
}
if (bundle->getVerbose() && removed > 0)
printf("Removed %d file%s\n", removed, (removed==1) ? "" : "s");
}
/* tell Zip lib to process deletions and other pending changes */
result = zip->flush();
if (result != NO_ERROR) {
fprintf(stderr, "ERROR: Zip flush failed, archive may be hosed\n");
goto bail;
}
/* anything here? */
if (zip->getNumEntries() == 0) {
if (bundle->getVerbose()) {
printf("Archive is empty -- removing %s\n", outputFile.getPathLeaf().string());
}
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 we've been asked to generate a dependency file for the .ap_ package,
// do so here
if (bundle->getGenDependencies()) {
// The dependency file gets output to the same directory
// as the specified output file with an additional .d extension.
// e.g. bin/resources.ap_.d
String8 dependencyFile = outputFile;
dependencyFile.append(".d");
FILE* fp = fopen(dependencyFile.string(), "a");
// Add this file to the dependency file
fprintf(fp, "%s \\\n", outputFile.string());
fclose(fp);
}
assert(result == NO_ERROR);
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());
}
if (unlink(outputFile.string()) != 0) {
fprintf(stderr, "warning: could not unlink '%s'\n", outputFile.string());
}
}
if (result == NO_ERROR && bundle->getVerbose())
printf("Done!\n");
#if BENCHMARK
fprintf(stdout, "BENCHMARK: End APK Bundling. Time Elapsed: %f ms \n",(clock() - startAPKTime)/1000.0);
#endif /* BENCHMARK */
return result;
}
示例3: writeAPK
//.........这里部分代码省略.........
status_t status;
zip = new ZipFile;
status = zip->open(outputFile.string(), ZipFile::kOpenReadWrite | ZipFile::kOpenCreate);
if (status != NO_ERROR) {
fprintf(stderr, "ERROR: unable to open '%s' as Zip file for writing\n",
outputFile.string());
goto bail;
}
if (bundle->getVerbose()) {
printf("Writing all files...\n");
}
count = processAssets(bundle, zip, assets);
if (count < 0) {
fprintf(stderr, "ERROR: unable to process assets while packaging '%s'\n",
outputFile.string());
result = count;
goto bail;
}
if (bundle->getVerbose()) {
printf("Generated %d file%s\n", count, (count==1) ? "" : "s");
}
count = processJarFiles(bundle, zip);
if (count < 0) {
fprintf(stderr, "ERROR: unable to process jar files while packaging '%s'\n",
outputFile.string());
result = count;
goto bail;
}
if (bundle->getVerbose())
printf("Included %d file%s from jar/zip files.\n", count, (count==1) ? "" : "s");
result = NO_ERROR;
/*
* Check for cruft. We set the "marked" flag on all entries we created
* or decided not to update. If the entry isn't already slated for
* deletion, remove it now.
*/
{
if (bundle->getVerbose())
printf("Checking for deleted files\n");
int i, removed = 0;
for (i = 0; i < zip->getNumEntries(); i++) {
ZipEntry* entry = zip->getEntryByIndex(i);
if (!entry->getMarked() && entry->getDeleted()) {
if (bundle->getVerbose()) {
printf(" (removing crufty '%s')\n",
entry->getFileName());
}
zip->remove(entry);
removed++;
}
}
if (bundle->getVerbose() && removed > 0)
printf("Removed %d file%s\n", removed, (removed==1) ? "" : "s");
}
/* tell Zip lib to process deletions and other pending changes */
result = zip->flush();
if (result != NO_ERROR) {
fprintf(stderr, "ERROR: Zip flush failed, archive may be hosed\n");
goto bail;
}
/* anything here? */
if (zip->getNumEntries() == 0) {
if (bundle->getVerbose()) {
printf("Archive is empty -- removing %s\n", outputFile.getPathLeaf().string());
}
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());
}
}
assert(result == NO_ERROR);
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());
}
if (unlink(outputFile.string()) != 0) {
fprintf(stderr, "warning: could not unlink '%s'\n", outputFile.string());
}
}
if (result == NO_ERROR && bundle->getVerbose())
printf("Done!\n");
return result;
}