本文整理汇总了C++中String8::convertToResPath方法的典型用法代码示例。如果您正苦于以下问题:C++ String8::convertToResPath方法的具体用法?C++ String8::convertToResPath怎么用?C++ String8::convertToResPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String8
的用法示例。
在下文中一共展示了String8::convertToResPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processOverlayFile
/*
* 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.
*/
bool processOverlayFile(Bundle* bundle, ZipFile* zip,
String8 storageName, const sp<const AaptFile>& file)
{
const bool hasData = file->hasData();
storageName.convertToResPath();
ZipEntry* entry;
bool fromGzip = false;
status_t result;
if (strcasecmp(storageName.getPathExtension().string(), ".gz") == 0) {
fromGzip = true;
storageName = storageName.getBasePath();
}
if (bundle->getUpdate()) {
entry = zip->getEntryByName(storageName.string());
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());
return false;
}
zip->remove(entry);
}
}
if (hasData) {
const char* name = storageName.string();
if (endsWith(name, ".9.png") || endsWith(name, ".xml") || endsWith(name, ".arsc")) {
result = zip->add(file->getData(), file->getSize(), storageName.string(),
file->getCompressionMethod(), &entry);
if (result == NO_ERROR) {
if (bundle->getVerbose()) {
printf(" '%s'%s", storageName.string(), fromGzip ? " (from .gz)" : "");
if (entry->getCompressionMethod() == ZipEntry::kCompressStored) {
printf(" (not compressed)\n");
} else {
printf(" (compressed %d%%)\n", calcPercent(entry->getUncompressedLen(),
entry->getCompressedLen()));
}
}
entry->setMarked(true);
} else {
if (result == ALREADY_EXISTS) {
fprintf(stderr, " Unable to add '%s': file already in archive (try '-u'?)\n",
file->getPrintableSource().string());
} else {
fprintf(stderr, " Unable to add '%s': Zip add failed\n",
file->getPrintableSource().string());
}
return false;
}
}
}
return true;
}