| // Copyright 2021 PDFium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| #include "core/fxcrt/fx_folder.h" |
| #include "build/build_config.h" |
| #include "core/fxcrt/unowned_ptr.h" |
| #error "built on wrong platform" |
| FX_FolderHandle* FX_OpenFolder(const char* path) { |
| auto handle = std::make_unique<FX_FolderHandle>(); |
| DIR* dir = opendir(path); |
| bool FX_GetNextFile(FX_FolderHandle* handle, |
| struct dirent* de = readdir(handle->m_Dir); |
| ByteString fullpath = handle->m_Path + "/" + de->d_name; |
| if (stat(fullpath.c_str(), &deStat) < 0) |
| *bFolder = S_ISDIR(deStat.st_mode); |
| void FX_CloseFolder(FX_FolderHandle* handle) { |
| closedir(handle->m_Dir.Release()); |