summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-08-31 16:02:49 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-31 20:15:04 +0000
commit203188ac4275f83cf984b8a807b07b74ab139236 (patch)
treef5c9782de5b8190386a0e5876816d5168c9b61eb
parent3c6b72f79fce629c903ce31f07092df23f870bb6 (diff)
downloadpdfium-203188ac4275f83cf984b8a807b07b74ab139236.tar.xz
Move stream code into fx_stream.cpp
This CL moves methods defined in fx_stream.h into the fx_stream.cpp file. Change-Id: I32147d18dd7f4a29c228f11d108ac01cb891b290 Reviewed-on: https://pdfium-review.googlesource.com/12672 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r--core/fxcrt/fx_basic_util.cpp57
-rw-r--r--core/fxcrt/fx_stream.cpp55
2 files changed, 56 insertions, 56 deletions
diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp
index a636b6cb42..704fd18418 100644
--- a/core/fxcrt/fx_basic_util.cpp
+++ b/core/fxcrt/fx_basic_util.cpp
@@ -6,62 +6,7 @@
#include <algorithm>
-#include "core/fxcrt/fx_stream.h"
-#include "third_party/base/ptr_util.h"
-
-FX_FileHandle* FX_OpenFolder(const char* path) {
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- auto pData = pdfium::MakeUnique<CFindFileDataA>();
- pData->m_Handle = FindFirstFileExA((CFX_ByteString(path) + "/*.*").c_str(),
- FindExInfoStandard, &pData->m_FindData,
- FindExSearchNameMatch, nullptr, 0);
- if (pData->m_Handle == INVALID_HANDLE_VALUE)
- return nullptr;
-
- pData->m_bEnd = false;
- return pData.release();
-#else
- return opendir(path);
-#endif
-}
-
-bool FX_GetNextFile(FX_FileHandle* handle,
- CFX_ByteString* filename,
- bool* bFolder) {
- if (!handle)
- return false;
-
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- if (handle->m_bEnd)
- return false;
-
- *filename = handle->m_FindData.cFileName;
- *bFolder =
- (handle->m_FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
- if (!FindNextFileA(handle->m_Handle, &handle->m_FindData))
- handle->m_bEnd = true;
- return true;
-#else
- struct dirent* de = readdir(handle);
- if (!de)
- return false;
- *filename = de->d_name;
- *bFolder = de->d_type == DT_DIR;
- return true;
-#endif
-}
-
-void FX_CloseFolder(FX_FileHandle* handle) {
- if (!handle)
- return;
-
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- FindClose(handle->m_Handle);
- delete handle;
-#else
- closedir(handle);
-#endif
-}
+#include "core/fxcrt/fx_system.h"
uint32_t GetBits32(const uint8_t* pData, int bitpos, int nbits) {
ASSERT(0 < nbits && nbits <= 32);
diff --git a/core/fxcrt/fx_stream.cpp b/core/fxcrt/fx_stream.cpp
index a64b239546..0cf34aa22e 100644
--- a/core/fxcrt/fx_stream.cpp
+++ b/core/fxcrt/fx_stream.cpp
@@ -13,6 +13,7 @@
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/ifxcrt_fileaccess.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -97,3 +98,57 @@ bool IFX_SeekableStream::WriteBlock(const void* buffer, size_t size) {
bool IFX_SeekableStream::WriteString(const CFX_ByteStringC& str) {
return WriteBlock(str.unterminated_c_str(), str.GetLength());
}
+
+FX_FileHandle* FX_OpenFolder(const char* path) {
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+ auto pData = pdfium::MakeUnique<CFindFileDataA>();
+ pData->m_Handle = FindFirstFileExA((CFX_ByteString(path) + "/*.*").c_str(),
+ FindExInfoStandard, &pData->m_FindData,
+ FindExSearchNameMatch, nullptr, 0);
+ if (pData->m_Handle == INVALID_HANDLE_VALUE)
+ return nullptr;
+
+ pData->m_bEnd = false;
+ return pData.release();
+#else
+ return opendir(path);
+#endif
+}
+
+bool FX_GetNextFile(FX_FileHandle* handle,
+ CFX_ByteString* filename,
+ bool* bFolder) {
+ if (!handle)
+ return false;
+
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+ if (handle->m_bEnd)
+ return false;
+
+ *filename = handle->m_FindData.cFileName;
+ *bFolder =
+ (handle->m_FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
+ if (!FindNextFileA(handle->m_Handle, &handle->m_FindData))
+ handle->m_bEnd = true;
+ return true;
+#else
+ struct dirent* de = readdir(handle);
+ if (!de)
+ return false;
+ *filename = de->d_name;
+ *bFolder = de->d_type == DT_DIR;
+ return true;
+#endif
+}
+
+void FX_CloseFolder(FX_FileHandle* handle) {
+ if (!handle)
+ return;
+
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+ FindClose(handle->m_Handle);
+ delete handle;
+#else
+ closedir(handle);
+#endif
+}