summaryrefslogtreecommitdiff
path: root/core/fxge/android
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-03 17:54:39 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-03 17:54:39 +0000
commitcaca3e0bb0d5ae31f60e2904986f231a6f9ad659 (patch)
treefdb6cade6dee547ad1912ffd34d5b8962ebad018 /core/fxge/android
parentf9e0498bb1ce2a52628065bc13389b4fc2768f42 (diff)
downloadpdfium-caca3e0bb0d5ae31f60e2904986f231a6f9ad659.tar.xz
Add FxFolderHandleCloser for use with std::unique_ptr.
Use it in a couple of places. Make the similar code in the two places even more so. Change-Id: I3fc6a567088217e24506cdf7ab927b94cb5a4d52 Reviewed-on: https://pdfium-review.googlesource.com/43330 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxge/android')
-rw-r--r--core/fxge/android/cfpf_skiafontmgr.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp
index 2288a86e92..2aec56a628 100644
--- a/core/fxge/android/cfpf_skiafontmgr.cpp
+++ b/core/fxge/android/cfpf_skiafontmgr.cpp
@@ -348,12 +348,14 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const ByteStringView& bsFile,
}
void CFPF_SkiaFontMgr::ScanPath(const ByteString& path) {
- DIR* handle = FX_OpenFolder(path.c_str());
+ std::unique_ptr<FX_FileHandle, FxFolderHandleCloser> handle(
+ FX_OpenFolder(path.c_str()));
if (!handle)
return;
+
ByteString filename;
bool bFolder = false;
- while (FX_GetNextFile(handle, &filename, &bFolder)) {
+ while (FX_GetNextFile(handle.get(), &filename, &bFolder)) {
if (bFolder) {
if (filename == "." || filename == "..")
continue;
@@ -371,7 +373,6 @@ void CFPF_SkiaFontMgr::ScanPath(const ByteString& path) {
else
ScanFile(fullpath);
}
- FX_CloseFolder(handle);
}
void CFPF_SkiaFontMgr::ScanFile(const ByteString& file) {