Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(827)

Unified Diff: src/ports/SkFontMgr_android_parser.cpp

Issue 2279033004: SkOSFile instead of dirent in android font parser. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontMgr_android_parser.cpp
diff --git a/src/ports/SkFontMgr_android_parser.cpp b/src/ports/SkFontMgr_android_parser.cpp
index 24242830cee56c1f85b302faa30e830feb923f1f..f4f74074ac81ac4e4495a09de258e2c7dc4bf0ca 100644
--- a/src/ports/SkFontMgr_android_parser.cpp
+++ b/src/ports/SkFontMgr_android_parser.cpp
@@ -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))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698