From caca3e0bb0d5ae31f60e2904986f231a6f9ad659 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 3 Oct 2018 17:54:39 +0000 Subject: 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 Commit-Queue: Lei Zhang --- core/fxcrt/fx_stream.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'core/fxcrt') diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h index b41d413723..5d473782a4 100644 --- a/core/fxcrt/fx_stream.h +++ b/core/fxcrt/fx_stream.h @@ -28,6 +28,11 @@ FX_FileHandle* FX_OpenFolder(const char* path); bool FX_GetNextFile(FX_FileHandle* handle, ByteString* filename, bool* bFolder); void FX_CloseFolder(FX_FileHandle* handle); +// Used with std::unique_ptr to automatically call FX_CloseFolder(). +struct FxFolderHandleCloser { + inline void operator()(FX_FileHandle* h) const { FX_CloseFolder(h); } +}; + #define FX_FILEMODE_ReadOnly 1 #define FX_FILEMODE_Truncate 2 -- cgit v1.2.3