summaryrefslogtreecommitdiff
path: root/core
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
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')
-rw-r--r--core/fxcrt/cfx_fileaccess_posix.cpp (renamed from core/fxcrt/fxcrt_posix.cpp)62
-rw-r--r--core/fxcrt/cfx_fileaccess_posix.h (renamed from core/fxcrt/fxcrt_posix.h)16
-rw-r--r--core/fxcrt/cfx_fileaccess_windows.cpp (renamed from core/fxcrt/fxcrt_windows.cpp)66
-rw-r--r--core/fxcrt/cfx_fileaccess_windows.h (renamed from core/fxcrt/fxcrt_windows.h)16
-rw-r--r--core/fxcrt/fx_stream.cpp10
-rw-r--r--core/fxcrt/ifx_fileaccess.h (renamed from core/fxcrt/ifxcrt_fileaccess.h)12
6 files changed, 95 insertions, 87 deletions
diff --git a/core/fxcrt/fxcrt_posix.cpp b/core/fxcrt/cfx_fileaccess_posix.cpp
index c206268029..345b6641ef 100644
--- a/core/fxcrt/fxcrt_posix.cpp
+++ b/core/fxcrt/cfx_fileaccess_posix.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fxcrt/fxcrt_posix.h"
+#include "core/fxcrt/cfx_fileaccess_posix.h"
#include <memory>
@@ -22,14 +22,9 @@
_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \
_FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_
-// static
-std::unique_ptr<IFXCRT_FileAccess> IFXCRT_FileAccess::Create() {
- return pdfium::MakeUnique<CFXCRT_FileAccess_Posix>();
-}
+namespace {
-void FXCRT_Posix_GetFileMode(uint32_t dwModes,
- int32_t& nFlags,
- int32_t& nMasks) {
+void GetFileMode(uint32_t dwModes, int32_t& nFlags, int32_t& nMasks) {
nFlags = O_BINARY | O_LARGEFILE;
if (dwModes & FX_FILEMODE_ReadOnly) {
nFlags |= O_RDONLY;
@@ -42,38 +37,47 @@ void FXCRT_Posix_GetFileMode(uint32_t dwModes,
nMasks = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
}
}
-CFXCRT_FileAccess_Posix::CFXCRT_FileAccess_Posix() : m_nFD(-1) {}
-CFXCRT_FileAccess_Posix::~CFXCRT_FileAccess_Posix() {
+
+} // namespace
+
+// static
+std::unique_ptr<IFX_FileAccess> IFX_FileAccess::Create() {
+ return pdfium::MakeUnique<CFX_FileAccess_Posix>();
+}
+
+CFX_FileAccess_Posix::CFX_FileAccess_Posix() : m_nFD(-1) {}
+
+CFX_FileAccess_Posix::~CFX_FileAccess_Posix() {
Close();
}
-bool CFXCRT_FileAccess_Posix::Open(const CFX_ByteStringC& fileName,
- uint32_t dwMode) {
+bool CFX_FileAccess_Posix::Open(const CFX_ByteStringC& fileName,
+ uint32_t dwMode) {
if (m_nFD > -1)
return false;
int32_t nFlags;
int32_t nMasks;
- FXCRT_Posix_GetFileMode(dwMode, nFlags, nMasks);
+ GetFileMode(dwMode, nFlags, nMasks);
// TODO(tsepez): check usage of c_str() below.
m_nFD = open(fileName.unterminated_c_str(), nFlags, nMasks);
return m_nFD > -1;
}
-bool CFXCRT_FileAccess_Posix::Open(const CFX_WideStringC& fileName,
- uint32_t dwMode) {
+bool CFX_FileAccess_Posix::Open(const CFX_WideStringC& fileName,
+ uint32_t dwMode) {
return Open(FX_UTF8Encode(fileName).AsStringC(), dwMode);
}
-void CFXCRT_FileAccess_Posix::Close() {
+void CFX_FileAccess_Posix::Close() {
if (m_nFD < 0) {
return;
}
close(m_nFD);
m_nFD = -1;
}
-FX_FILESIZE CFXCRT_FileAccess_Posix::GetSize() const {
+FX_FILESIZE CFX_FileAccess_Posix::GetSize() const {
if (m_nFD < 0) {
return 0;
}
@@ -82,33 +86,33 @@ FX_FILESIZE CFXCRT_FileAccess_Posix::GetSize() const {
fstat(m_nFD, &s);
return s.st_size;
}
-FX_FILESIZE CFXCRT_FileAccess_Posix::GetPosition() const {
+FX_FILESIZE CFX_FileAccess_Posix::GetPosition() const {
if (m_nFD < 0) {
return (FX_FILESIZE)-1;
}
return lseek(m_nFD, 0, SEEK_CUR);
}
-FX_FILESIZE CFXCRT_FileAccess_Posix::SetPosition(FX_FILESIZE pos) {
+FX_FILESIZE CFX_FileAccess_Posix::SetPosition(FX_FILESIZE pos) {
if (m_nFD < 0) {
return (FX_FILESIZE)-1;
}
return lseek(m_nFD, pos, SEEK_SET);
}
-size_t CFXCRT_FileAccess_Posix::Read(void* pBuffer, size_t szBuffer) {
+size_t CFX_FileAccess_Posix::Read(void* pBuffer, size_t szBuffer) {
if (m_nFD < 0) {
return 0;
}
return read(m_nFD, pBuffer, szBuffer);
}
-size_t CFXCRT_FileAccess_Posix::Write(const void* pBuffer, size_t szBuffer) {
+size_t CFX_FileAccess_Posix::Write(const void* pBuffer, size_t szBuffer) {
if (m_nFD < 0) {
return 0;
}
return write(m_nFD, pBuffer, szBuffer);
}
-size_t CFXCRT_FileAccess_Posix::ReadPos(void* pBuffer,
- size_t szBuffer,
- FX_FILESIZE pos) {
+size_t CFX_FileAccess_Posix::ReadPos(void* pBuffer,
+ size_t szBuffer,
+ FX_FILESIZE pos) {
if (m_nFD < 0) {
return 0;
}
@@ -120,9 +124,9 @@ size_t CFXCRT_FileAccess_Posix::ReadPos(void* pBuffer,
}
return Read(pBuffer, szBuffer);
}
-size_t CFXCRT_FileAccess_Posix::WritePos(const void* pBuffer,
- size_t szBuffer,
- FX_FILESIZE pos) {
+size_t CFX_FileAccess_Posix::WritePos(const void* pBuffer,
+ size_t szBuffer,
+ FX_FILESIZE pos) {
if (m_nFD < 0) {
return 0;
}
@@ -132,14 +136,14 @@ size_t CFXCRT_FileAccess_Posix::WritePos(const void* pBuffer,
return Write(pBuffer, szBuffer);
}
-bool CFXCRT_FileAccess_Posix::Flush() {
+bool CFX_FileAccess_Posix::Flush() {
if (m_nFD < 0)
return false;
return fsync(m_nFD) > -1;
}
-bool CFXCRT_FileAccess_Posix::Truncate(FX_FILESIZE szFile) {
+bool CFX_FileAccess_Posix::Truncate(FX_FILESIZE szFile) {
if (m_nFD < 0)
return false;
diff --git a/core/fxcrt/fxcrt_posix.h b/core/fxcrt/cfx_fileaccess_posix.h
index 109cf34a51..c299f6cc34 100644
--- a/core/fxcrt/fxcrt_posix.h
+++ b/core/fxcrt/cfx_fileaccess_posix.h
@@ -4,20 +4,20 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FXCRT_FXCRT_POSIX_H_
-#define CORE_FXCRT_FXCRT_POSIX_H_
+#ifndef CORE_FXCRT_CFX_FILEACCESS_POSIX_H_
+#define CORE_FXCRT_CFX_FILEACCESS_POSIX_H_
-#include "core/fxcrt/ifxcrt_fileaccess.h"
+#include "core/fxcrt/ifx_fileaccess.h"
#if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \
_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \
_FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_
-class CFXCRT_FileAccess_Posix : public IFXCRT_FileAccess {
+class CFX_FileAccess_Posix : public IFX_FileAccess {
public:
- CFXCRT_FileAccess_Posix();
- ~CFXCRT_FileAccess_Posix() override;
+ CFX_FileAccess_Posix();
+ ~CFX_FileAccess_Posix() override;
- // IFXCRT_FileAccess:
+ // IFX_FileAccess:
bool Open(const CFX_ByteStringC& fileName, uint32_t dwMode) override;
bool Open(const CFX_WideStringC& fileName, uint32_t dwMode) override;
void Close() override;
@@ -38,4 +38,4 @@ class CFXCRT_FileAccess_Posix : public IFXCRT_FileAccess {
};
#endif
-#endif // CORE_FXCRT_FXCRT_POSIX_H_
+#endif // CORE_FXCRT_CFX_FILEACCESS_POSIX_H_
diff --git a/core/fxcrt/fxcrt_windows.cpp b/core/fxcrt/cfx_fileaccess_windows.cpp
index 1a2a36735e..b39a4d6efc 100644
--- a/core/fxcrt/fxcrt_windows.cpp
+++ b/core/fxcrt/cfx_fileaccess_windows.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fxcrt/fxcrt_windows.h"
+#include "core/fxcrt/cfx_fileaccess_windows.h"
#include <memory>
@@ -13,15 +13,12 @@
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-// static
-std::unique_ptr<IFXCRT_FileAccess> IFXCRT_FileAccess::Create() {
- return pdfium::MakeUnique<CFXCRT_FileAccess_Win64>();
-}
+namespace {
-void FXCRT_Windows_GetFileMode(uint32_t dwMode,
- uint32_t& dwAccess,
- uint32_t& dwShare,
- uint32_t& dwCreation) {
+void 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)) {
@@ -32,6 +29,13 @@ void FXCRT_Windows_GetFileMode(uint32_t dwMode,
}
}
+} // namespace
+
+// static
+std::unique_ptr<IFX_FileAccess> IFX_FileAccess::Create() {
+ return pdfium::MakeUnique<CFX_FileAccess_Windows>();
+}
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -44,19 +48,19 @@ WINBASEAPI BOOL WINAPI SetFilePointerEx(HANDLE hFile,
}
#endif
-CFXCRT_FileAccess_Win64::CFXCRT_FileAccess_Win64() : m_hFile(nullptr) {}
+CFX_FileAccess_Windows::CFX_FileAccess_Windows() : m_hFile(nullptr) {}
-CFXCRT_FileAccess_Win64::~CFXCRT_FileAccess_Win64() {
+CFX_FileAccess_Windows::~CFX_FileAccess_Windows() {
Close();
}
-bool CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName,
- uint32_t dwMode) {
+bool CFX_FileAccess_Windows::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);
+ 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)
@@ -65,13 +69,13 @@ bool CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName,
return !!m_hFile;
}
-bool CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName,
- uint32_t dwMode) {
+bool CFX_FileAccess_Windows::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);
+ GetFileMode(dwMode, dwAccess, dwShare, dwCreation);
m_hFile =
::CreateFileW((LPCWSTR)fileName.unterminated_c_str(), dwAccess, dwShare,
nullptr, dwCreation, FILE_ATTRIBUTE_NORMAL, nullptr);
@@ -81,7 +85,7 @@ bool CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName,
return !!m_hFile;
}
-void CFXCRT_FileAccess_Win64::Close() {
+void CFX_FileAccess_Windows::Close() {
if (!m_hFile)
return;
@@ -89,7 +93,7 @@ void CFXCRT_FileAccess_Win64::Close() {
m_hFile = nullptr;
}
-FX_FILESIZE CFXCRT_FileAccess_Win64::GetSize() const {
+FX_FILESIZE CFX_FileAccess_Windows::GetSize() const {
if (!m_hFile)
return 0;
@@ -100,7 +104,7 @@ FX_FILESIZE CFXCRT_FileAccess_Win64::GetSize() const {
return (FX_FILESIZE)size.QuadPart;
}
-FX_FILESIZE CFXCRT_FileAccess_Win64::GetPosition() const {
+FX_FILESIZE CFX_FileAccess_Windows::GetPosition() const {
if (!m_hFile)
return (FX_FILESIZE)-1;
@@ -112,7 +116,7 @@ FX_FILESIZE CFXCRT_FileAccess_Win64::GetPosition() const {
return (FX_FILESIZE)newPos.QuadPart;
}
-FX_FILESIZE CFXCRT_FileAccess_Win64::SetPosition(FX_FILESIZE pos) {
+FX_FILESIZE CFX_FileAccess_Windows::SetPosition(FX_FILESIZE pos) {
if (!m_hFile)
return (FX_FILESIZE)-1;
@@ -125,7 +129,7 @@ FX_FILESIZE CFXCRT_FileAccess_Win64::SetPosition(FX_FILESIZE pos) {
return (FX_FILESIZE)newPos.QuadPart;
}
-size_t CFXCRT_FileAccess_Win64::Read(void* pBuffer, size_t szBuffer) {
+size_t CFX_FileAccess_Windows::Read(void* pBuffer, size_t szBuffer) {
if (!m_hFile)
return 0;
@@ -137,7 +141,7 @@ size_t CFXCRT_FileAccess_Win64::Read(void* pBuffer, size_t szBuffer) {
return szRead;
}
-size_t CFXCRT_FileAccess_Win64::Write(const void* pBuffer, size_t szBuffer) {
+size_t CFX_FileAccess_Windows::Write(const void* pBuffer, size_t szBuffer) {
if (!m_hFile)
return 0;
@@ -149,9 +153,9 @@ size_t CFXCRT_FileAccess_Win64::Write(const void* pBuffer, size_t szBuffer) {
return szWrite;
}
-size_t CFXCRT_FileAccess_Win64::ReadPos(void* pBuffer,
- size_t szBuffer,
- FX_FILESIZE pos) {
+size_t CFX_FileAccess_Windows::ReadPos(void* pBuffer,
+ size_t szBuffer,
+ FX_FILESIZE pos) {
if (!m_hFile)
return 0;
@@ -164,9 +168,9 @@ size_t CFXCRT_FileAccess_Win64::ReadPos(void* pBuffer,
return Read(pBuffer, szBuffer);
}
-size_t CFXCRT_FileAccess_Win64::WritePos(const void* pBuffer,
- size_t szBuffer,
- FX_FILESIZE pos) {
+size_t CFX_FileAccess_Windows::WritePos(const void* pBuffer,
+ size_t szBuffer,
+ FX_FILESIZE pos) {
if (!m_hFile) {
return 0;
}
@@ -176,14 +180,14 @@ size_t CFXCRT_FileAccess_Win64::WritePos(const void* pBuffer,
return Write(pBuffer, szBuffer);
}
-bool CFXCRT_FileAccess_Win64::Flush() {
+bool CFX_FileAccess_Windows::Flush() {
if (!m_hFile)
return false;
return !!::FlushFileBuffers(m_hFile);
}
-bool CFXCRT_FileAccess_Win64::Truncate(FX_FILESIZE szFile) {
+bool CFX_FileAccess_Windows::Truncate(FX_FILESIZE szFile) {
if (SetPosition(szFile) == (FX_FILESIZE)-1)
return false;
diff --git a/core/fxcrt/fxcrt_windows.h b/core/fxcrt/cfx_fileaccess_windows.h
index 8e800ce4d6..692a537a82 100644
--- a/core/fxcrt/fxcrt_windows.h
+++ b/core/fxcrt/cfx_fileaccess_windows.h
@@ -4,18 +4,18 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FXCRT_FXCRT_WINDOWS_H_
-#define CORE_FXCRT_FXCRT_WINDOWS_H_
+#ifndef CORE_FXCRT_CFX_FILEACCESS_WINDOWS_H_
+#define CORE_FXCRT_CFX_FILEACCESS_WINDOWS_H_
-#include "core/fxcrt/ifxcrt_fileaccess.h"
+#include "core/fxcrt/ifx_fileaccess.h"
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-class CFXCRT_FileAccess_Win64 : public IFXCRT_FileAccess {
+class CFX_FileAccess_Windows : public IFX_FileAccess {
public:
- CFXCRT_FileAccess_Win64();
- ~CFXCRT_FileAccess_Win64() override;
+ CFX_FileAccess_Windows();
+ ~CFX_FileAccess_Windows() override;
- // IFXCRT_FileAccess
+ // IFX_FileAccess
bool Open(const CFX_ByteStringC& fileName, uint32_t dwMode) override;
bool Open(const CFX_WideStringC& fileName, uint32_t dwMode) override;
void Close() override;
@@ -36,4 +36,4 @@ class CFXCRT_FileAccess_Win64 : public IFXCRT_FileAccess {
};
#endif
-#endif // CORE_FXCRT_FXCRT_WINDOWS_H_
+#endif // CORE_FXCRT_CFX_FILEACCESS_WINDOWS_H_
diff --git a/core/fxcrt/fx_stream.cpp b/core/fxcrt/fx_stream.cpp
index 0cf34aa22e..c269ec91ed 100644
--- a/core/fxcrt/fx_stream.cpp
+++ b/core/fxcrt/fx_stream.cpp
@@ -12,7 +12,7 @@
#include <vector>
#include "core/fxcrt/fx_safe_types.h"
-#include "core/fxcrt/ifxcrt_fileaccess.h"
+#include "core/fxcrt/ifx_fileaccess.h"
#include "third_party/base/ptr_util.h"
namespace {
@@ -40,11 +40,11 @@ class CFX_CRTFileStream final : public IFX_SeekableStream {
bool Flush() override { return m_pFile->Flush(); }
private:
- explicit CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA)
+ explicit CFX_CRTFileStream(std::unique_ptr<IFX_FileAccess> pFA)
: m_pFile(std::move(pFA)) {}
~CFX_CRTFileStream() override {}
- std::unique_ptr<IFXCRT_FileAccess> m_pFile;
+ std::unique_ptr<IFX_FileAccess> m_pFile;
};
} // namespace
@@ -53,7 +53,7 @@ class CFX_CRTFileStream final : public IFX_SeekableStream {
CFX_RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename(
const char* filename,
uint32_t dwModes) {
- std::unique_ptr<IFXCRT_FileAccess> pFA = IFXCRT_FileAccess::Create();
+ std::unique_ptr<IFX_FileAccess> pFA = IFX_FileAccess::Create();
if (!pFA->Open(filename, dwModes))
return nullptr;
return pdfium::MakeRetain<CFX_CRTFileStream>(std::move(pFA));
@@ -63,7 +63,7 @@ CFX_RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename(
CFX_RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename(
const wchar_t* filename,
uint32_t dwModes) {
- std::unique_ptr<IFXCRT_FileAccess> pFA = IFXCRT_FileAccess::Create();
+ std::unique_ptr<IFX_FileAccess> pFA = IFX_FileAccess::Create();
if (!pFA->Open(filename, dwModes))
return nullptr;
return pdfium::MakeRetain<CFX_CRTFileStream>(std::move(pFA));
diff --git a/core/fxcrt/ifxcrt_fileaccess.h b/core/fxcrt/ifx_fileaccess.h
index f4c686abd5..e818303d85 100644
--- a/core/fxcrt/ifxcrt_fileaccess.h
+++ b/core/fxcrt/ifx_fileaccess.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FXCRT_IFXCRT_FILEACCESS_H_
-#define CORE_FXCRT_IFXCRT_FILEACCESS_H_
+#ifndef CORE_FXCRT_IFX_FILEACCESS_H_
+#define CORE_FXCRT_IFX_FILEACCESS_H_
#include <algorithm>
#include <memory>
@@ -14,10 +14,10 @@
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/fx_string.h"
-class IFXCRT_FileAccess {
+class IFX_FileAccess {
public:
- static std::unique_ptr<IFXCRT_FileAccess> Create();
- virtual ~IFXCRT_FileAccess() {}
+ static std::unique_ptr<IFX_FileAccess> Create();
+ virtual ~IFX_FileAccess() {}
virtual bool Open(const CFX_ByteStringC& fileName, uint32_t dwMode) = 0;
virtual bool Open(const CFX_WideStringC& fileName, uint32_t dwMode) = 0;
@@ -35,4 +35,4 @@ class IFXCRT_FileAccess {
virtual bool Truncate(FX_FILESIZE szFile) = 0;
};
-#endif // CORE_FXCRT_IFXCRT_FILEACCESS_H_
+#endif // CORE_FXCRT_IFX_FILEACCESS_H_