summaryrefslogtreecommitdiff
path: root/core/fxcrt/fxcrt_windows.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-08-31 16:31:47 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-31 20:58:54 +0000
commit1e8dd54c54a04d5f5ee249db22f84001fa16101e (patch)
treea5eebcc6d3bcd9dd8b0aed535b0aa997fde4448e /core/fxcrt/fxcrt_windows.cpp
parentc5ac05726a38d214d399f7be42811d659f9f9d9a (diff)
downloadpdfium-1e8dd54c54a04d5f5ee249db22f84001fa16101e.tar.xz
Rename fxcrt_ and ifxcrt_ files to better names
The CFXCRT and IFXCRT prefix was only used on 3 files. This CL renames them to the more common CFX and IFX. The files were renamed as needed. Change-Id: Iccdaa55c5822adb93af7c58aedfb121413a30223 Reviewed-on: https://pdfium-review.googlesource.com/12675 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/fxcrt_windows.cpp')
-rw-r--r--core/fxcrt/fxcrt_windows.cpp192
1 files changed, 0 insertions, 192 deletions
diff --git a/core/fxcrt/fxcrt_windows.cpp b/core/fxcrt/fxcrt_windows.cpp
deleted file mode 100644
index 1a2a36735e..0000000000
--- a/core/fxcrt/fxcrt_windows.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright 2014 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/fxcrt_windows.h"
-
-#include <memory>
-
-#include "core/fxcrt/fx_string.h"
-#include "third_party/base/ptr_util.h"
-
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-
-// static
-std::unique_ptr<IFXCRT_FileAccess> IFXCRT_FileAccess::Create() {
- return pdfium::MakeUnique<CFXCRT_FileAccess_Win64>();
-}
-
-void FXCRT_Windows_GetFileMode(uint32_t dwMode,
- uint32_t& dwAccess,
- uint32_t& dwShare,
- uint32_t& dwCreation) {
- dwAccess = GENERIC_READ;
- dwShare = FILE_SHARE_READ | FILE_SHARE_WRITE;
- if (!(dwMode & FX_FILEMODE_ReadOnly)) {
- dwAccess |= GENERIC_WRITE;
- dwCreation = (dwMode & FX_FILEMODE_Truncate) ? CREATE_ALWAYS : OPEN_ALWAYS;
- } else {
- dwCreation = OPEN_EXISTING;
- }
-}
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-WINBASEAPI BOOL WINAPI GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize);
-WINBASEAPI BOOL WINAPI SetFilePointerEx(HANDLE hFile,
- LARGE_INTEGER liDistanceToMove,
- PLARGE_INTEGER lpNewFilePointer,
- DWORD dwMoveMethod);
-#ifdef __cplusplus
-}
-#endif
-
-CFXCRT_FileAccess_Win64::CFXCRT_FileAccess_Win64() : m_hFile(nullptr) {}
-
-CFXCRT_FileAccess_Win64::~CFXCRT_FileAccess_Win64() {
- Close();
-}
-
-bool CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName,
- uint32_t dwMode) {
- if (m_hFile)
- return false;
-
- uint32_t dwAccess, dwShare, dwCreation;
- FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation);
- m_hFile = ::CreateFileA(fileName.unterminated_c_str(), dwAccess, dwShare,
- nullptr, dwCreation, FILE_ATTRIBUTE_NORMAL, nullptr);
- if (m_hFile == INVALID_HANDLE_VALUE)
- m_hFile = nullptr;
-
- return !!m_hFile;
-}
-
-bool CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName,
- uint32_t dwMode) {
- if (m_hFile)
- return false;
-
- uint32_t dwAccess, dwShare, dwCreation;
- FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation);
- m_hFile =
- ::CreateFileW((LPCWSTR)fileName.unterminated_c_str(), dwAccess, dwShare,
- nullptr, dwCreation, FILE_ATTRIBUTE_NORMAL, nullptr);
- if (m_hFile == INVALID_HANDLE_VALUE)
- m_hFile = nullptr;
-
- return !!m_hFile;
-}
-
-void CFXCRT_FileAccess_Win64::Close() {
- if (!m_hFile)
- return;
-
- ::CloseHandle(m_hFile);
- m_hFile = nullptr;
-}
-
-FX_FILESIZE CFXCRT_FileAccess_Win64::GetSize() const {
- if (!m_hFile)
- return 0;
-
- LARGE_INTEGER size = {};
- if (!::GetFileSizeEx(m_hFile, &size))
- return 0;
-
- return (FX_FILESIZE)size.QuadPart;
-}
-
-FX_FILESIZE CFXCRT_FileAccess_Win64::GetPosition() const {
- if (!m_hFile)
- return (FX_FILESIZE)-1;
-
- LARGE_INTEGER dist = {};
- LARGE_INTEGER newPos = {};
- if (!::SetFilePointerEx(m_hFile, dist, &newPos, FILE_CURRENT))
- return (FX_FILESIZE)-1;
-
- return (FX_FILESIZE)newPos.QuadPart;
-}
-
-FX_FILESIZE CFXCRT_FileAccess_Win64::SetPosition(FX_FILESIZE pos) {
- if (!m_hFile)
- return (FX_FILESIZE)-1;
-
- LARGE_INTEGER dist;
- dist.QuadPart = pos;
- LARGE_INTEGER newPos = {};
- if (!::SetFilePointerEx(m_hFile, dist, &newPos, FILE_BEGIN))
- return (FX_FILESIZE)-1;
-
- return (FX_FILESIZE)newPos.QuadPart;
-}
-
-size_t CFXCRT_FileAccess_Win64::Read(void* pBuffer, size_t szBuffer) {
- if (!m_hFile)
- return 0;
-
- size_t szRead = 0;
- if (!::ReadFile(m_hFile, pBuffer, (DWORD)szBuffer, (LPDWORD)&szRead,
- nullptr)) {
- return 0;
- }
- return szRead;
-}
-
-size_t CFXCRT_FileAccess_Win64::Write(const void* pBuffer, size_t szBuffer) {
- if (!m_hFile)
- return 0;
-
- size_t szWrite = 0;
- if (!::WriteFile(m_hFile, pBuffer, (DWORD)szBuffer, (LPDWORD)&szWrite,
- nullptr)) {
- return 0;
- }
- return szWrite;
-}
-
-size_t CFXCRT_FileAccess_Win64::ReadPos(void* pBuffer,
- size_t szBuffer,
- FX_FILESIZE pos) {
- if (!m_hFile)
- return 0;
-
- if (pos >= GetSize())
- return 0;
-
- if (SetPosition(pos) == (FX_FILESIZE)-1)
- return 0;
-
- return Read(pBuffer, szBuffer);
-}
-
-size_t CFXCRT_FileAccess_Win64::WritePos(const void* pBuffer,
- size_t szBuffer,
- FX_FILESIZE pos) {
- if (!m_hFile) {
- return 0;
- }
- if (SetPosition(pos) == (FX_FILESIZE)-1) {
- return 0;
- }
- return Write(pBuffer, szBuffer);
-}
-
-bool CFXCRT_FileAccess_Win64::Flush() {
- if (!m_hFile)
- return false;
-
- return !!::FlushFileBuffers(m_hFile);
-}
-
-bool CFXCRT_FileAccess_Win64::Truncate(FX_FILESIZE szFile) {
- if (SetPosition(szFile) == (FX_FILESIZE)-1)
- return false;
-
- return !!::SetEndOfFile(m_hFile);
-}
-#endif