本文整理汇总了C++中SkString::startsWith方法的典型用法代码示例。如果您正苦于以下问题:C++ SkString::startsWith方法的具体用法?C++ SkString::startsWith怎么用?C++ SkString::startsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkString
的用法示例。
在下文中一共展示了SkString::startsWith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_file_list_subdir
/// Internal (potentially recursive) implementation of get_file_list.
static void get_file_list_subdir(const SkString& rootDir, const SkString& subDir,
const StringArray& matchSubstrings,
const StringArray& nomatchSubstrings,
bool recurseIntoSubdirs, FileArray *files) {
bool isSubDirEmpty = subDir.isEmpty();
SkString dir(rootDir);
if (!isSubDirEmpty) {
dir.append(PATH_DIV_STR);
dir.append(subDir);
}
// Iterate over files (not directories) within dir.
SkOSFile::Iter fileIterator(dir.c_str());
SkString fileName;
while (fileIterator.next(&fileName, false)) {
if (fileName.startsWith(".")) {
continue;
}
SkString pathRelativeToRootDir(subDir);
if (!isSubDirEmpty) {
pathRelativeToRootDir.append(PATH_DIV_STR);
}
pathRelativeToRootDir.append(fileName);
if (string_contains_any_of(pathRelativeToRootDir, matchSubstrings) &&
!string_contains_any_of(pathRelativeToRootDir, nomatchSubstrings)) {
files->push(new SkString(pathRelativeToRootDir));
}
}
// Recurse into any non-ignored subdirectories.
if (recurseIntoSubdirs) {
SkOSFile::Iter dirIterator(dir.c_str());
SkString dirName;
while (dirIterator.next(&dirName, true)) {
if (dirName.startsWith(".")) {
continue;
}
SkString pathRelativeToRootDir(subDir);
if (!isSubDirEmpty) {
pathRelativeToRootDir.append(PATH_DIV_STR);
}
pathRelativeToRootDir.append(dirName);
if (!string_contains_any_of(pathRelativeToRootDir, nomatchSubstrings)) {
get_file_list_subdir(rootDir, pathRelativeToRootDir,
matchSubstrings, nomatchSubstrings, recurseIntoSubdirs,
files);
}
}
}
}
示例2: load_directory_fonts
static void load_directory_fonts(const SkTypeface_FreeType::Scanner& scanner,
const SkString& directory, const char* suffix,
SkFontMgr_Custom::Families* families)
{
SkOSFile::Iter iter(directory.c_str(), suffix);
SkString name;
while (iter.next(&name, false)) {
SkString filename(SkOSPath::Join(directory.c_str(), name.c_str()));
SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(filename.c_str()));
if (!stream.get()) {
SkDebugf("---- failed to open <%s>\n", filename.c_str());
continue;
}
int numFaces;
if (!scanner.recognizedFont(stream, &numFaces)) {
SkDebugf("---- failed to open <%s> as a font\n", filename.c_str());
continue;
}
for (int faceIndex = 0; faceIndex < numFaces; ++faceIndex) {
bool isFixedPitch;
SkString realname;
SkFontStyle style = SkFontStyle(); // avoid uninitialized warning
if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isFixedPitch, NULL)) {
SkDebugf("---- failed to open <%s> <%d> as a font\n",
filename.c_str(), faceIndex);
continue;
}
SkTypeface_Custom* tf = SkNEW_ARGS(SkTypeface_File, (
style,
isFixedPitch,
true, // system-font (cannot delete)
realname,
filename.c_str(),
faceIndex));
SkFontStyleSet_Custom* addTo = find_family(*families, realname.c_str());
if (NULL == addTo) {
addTo = new SkFontStyleSet_Custom(realname);
families->push_back().reset(addTo);
}
addTo->appendTypeface(tf);
}
}
SkOSFile::Iter dirIter(directory.c_str());
while (dirIter.next(&name, true)) {
if (name.startsWith(".")) {
continue;
}
SkString dirname(SkOSPath::Join(directory.c_str(), name.c_str()));
load_directory_fonts(scanner, dirname, suffix, families);
}
}