SkOSFile instead of dirent in android font parser.
This makes the parser more portable while making essentially the same file system calls on Android. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2279033004 Review-Url: https://codereview.chromium.org/2279033004
This commit is contained in:
parent
164fd9fa46
commit
22cffcace2
@ -10,13 +10,13 @@
|
||||
#include "SkFixed.h"
|
||||
#include "SkFontMgr.h"
|
||||
#include "SkFontMgr_android_parser.h"
|
||||
#include "SkOSFile.h"
|
||||
#include "SkStream.h"
|
||||
#include "SkTDArray.h"
|
||||
#include "SkTSearch.h"
|
||||
#include "SkTemplates.h"
|
||||
#include "SkTLogic.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <expat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -676,12 +676,9 @@ static void append_fallback_font_families_for_locale(SkTDArray<FontFamily*>& fal
|
||||
const char* dir,
|
||||
const SkString& basePath)
|
||||
{
|
||||
SkAutoTCallIProc<DIR, closedir> fontDirectory(opendir(dir));
|
||||
if (nullptr == fontDirectory) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (struct dirent* dirEntry; (dirEntry = readdir(fontDirectory));) {
|
||||
SkOSFile::Iter iter(dir, nullptr);
|
||||
SkString fileName;
|
||||
while (iter.next(&fileName, false)) {
|
||||
// The size of the prefix and suffix.
|
||||
static const size_t fixedLen = sizeof(LOCALE_FALLBACK_FONTS_PREFIX) - 1
|
||||
+ sizeof(LOCALE_FALLBACK_FONTS_SUFFIX) - 1;
|
||||
@ -689,7 +686,6 @@ static void append_fallback_font_families_for_locale(SkTDArray<FontFamily*>& fal
|
||||
// The size of the prefix, suffix, and a minimum valid language code
|
||||
static const size_t minSize = fixedLen + 2;
|
||||
|
||||
SkString fileName(dirEntry->d_name);
|
||||
if (fileName.size() < minSize ||
|
||||
!fileName.startsWith(LOCALE_FALLBACK_FONTS_PREFIX) ||
|
||||
!fileName.endsWith(LOCALE_FALLBACK_FONTS_SUFFIX))
|
||||
|
Loading…
Reference in New Issue
Block a user