本文整理汇总了C++中String8::walkPath方法的典型用法代码示例。如果您正苦于以下问题:C++ String8::walkPath方法的具体用法?C++ String8::walkPath怎么用?C++ String8::walkPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String8
的用法示例。
在下文中一共展示了String8::walkPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
sp<AaptDir> AaptDir::makeDir(const String8& path)
{
String8 name;
String8 remain = path;
sp<AaptDir> subdir = this;
while (name = remain.walkPath(&remain), remain != "") {
subdir = subdir->makeDir(name);
}
ssize_t i = subdir->mDirs.indexOfKey(name);
if (i >= 0) {
return subdir->mDirs.valueAt(i);
}
sp<AaptDir> dir = new AaptDir(name, subdir->mPath.appendPathCopy(name));
subdir->mDirs.add(name, dir);
return dir;
}
示例2: entryName
ssize_t
AaptAssets::slurpResourceZip(Bundle* bundle, const char* filename)
{
int count = 0;
SortedVector<AaptGroupEntry> entries;
ZipFile* zip = new ZipFile;
status_t err = zip->open(filename, ZipFile::kOpenReadOnly);
if (err != NO_ERROR) {
fprintf(stderr, "error opening zip file %s\n", filename);
count = err;
delete zip;
return -1;
}
const int N = zip->getNumEntries();
for (int i=0; i<N; i++) {
ZipEntry* entry = zip->getEntryByIndex(i);
if (entry->getDeleted()) {
continue;
}
String8 entryName(entry->getFileName());
String8 dirName = entryName.getPathDir();
sp<AaptDir> dir = dirName == "" ? this : makeDir(dirName);
String8 resType;
AaptGroupEntry kind;
String8 remain;
if (entryName.walkPath(&remain) == kResourceDir) {
// these are the resources, pull their type out of the directory name
kind.initFromDirName(remain.walkPath().string(), &resType);
} else {
// these are untyped and don't have an AaptGroupEntry
}
if (entries.indexOf(kind) < 0) {
entries.add(kind);
mGroupEntries.add(kind);
}
// use the one from the zip file if they both exist.
dir->removeFile(entryName.getPathLeaf());
sp<AaptFile> file = new AaptFile(entryName, kind, resType);
status_t err = dir->addLeafFile(entryName.getPathLeaf(), file);
if (err != NO_ERROR) {
fprintf(stderr, "err=%s entryName=%s\n", strerror(err), entryName.string());
count = err;
goto bail;
}
file->setCompressionMethod(entry->getCompressionMethod());
#if 0
if (entryName == "AndroidManifest.xml") {
printf("AndroidManifest.xml\n");
}
printf("\n\nfile: %s\n", entryName.string());
#endif
size_t len = entry->getUncompressedLen();
void* data = zip->uncompress(entry);
void* buf = file->editData(len);
memcpy(buf, data, len);
#if 0
const int OFF = 0;
const unsigned char* p = (unsigned char*)data;
const unsigned char* end = p+len;
p += OFF;
for (int i=0; i<32 && p < end; i++) {
printf("0x%03x ", i*0x10 + OFF);
for (int j=0; j<0x10 && p < end; j++) {
printf(" %02x", *p);
p++;
}
printf("\n");
}
#endif
free(data);
count++;
}
bail:
delete zip;
return count;
}