From 375a86403b7fa8d17d7b142c270e2d8e33bb924f Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 11 Jan 2016 11:59:17 -0800 Subject: Merge to XFA: Switch most min/max macros to std::min/max. Fix lint errors along the way. R=tsepez@chromium.org TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1567343002 . (cherry picked from commit 9adfbb0920a258e916003b1ee9515e97879db82a) Review URL: https://codereview.chromium.org/1577503002 . --- core/src/fxcrt/fx_extension.cpp | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'core/src/fxcrt/fx_extension.cpp') diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp index 4669ac4be4..8a6987b066 100644 --- a/core/src/fxcrt/fx_extension.cpp +++ b/core/src/fxcrt/fx_extension.cpp @@ -14,6 +14,59 @@ #include #endif +CFX_CRTFileStream::CFX_CRTFileStream(IFXCRT_FileAccess* pFA) + : m_pFile(pFA), m_dwCount(1) {} + +CFX_CRTFileStream::~CFX_CRTFileStream() { + if (m_pFile) { + m_pFile->Release(); + } +} + +IFX_FileStream* CFX_CRTFileStream::Retain() { + m_dwCount++; + return this; +} + +void CFX_CRTFileStream::Release() { + FX_DWORD nCount = --m_dwCount; + if (!nCount) { + delete this; + } +} + +FX_FILESIZE CFX_CRTFileStream::GetSize() { + return m_pFile->GetSize(); +} + +FX_BOOL CFX_CRTFileStream::IsEOF() { + return GetPosition() >= GetSize(); +} + +FX_FILESIZE CFX_CRTFileStream::GetPosition() { + return m_pFile->GetPosition(); +} + +FX_BOOL CFX_CRTFileStream::ReadBlock(void* buffer, + FX_FILESIZE offset, + size_t size) { + return (FX_BOOL)m_pFile->ReadPos(buffer, size, offset); +} + +size_t CFX_CRTFileStream::ReadBlock(void* buffer, size_t size) { + return m_pFile->Read(buffer, size); +} + +FX_BOOL CFX_CRTFileStream::WriteBlock(const void* buffer, + FX_FILESIZE offset, + size_t size) { + return (FX_BOOL)m_pFile->WritePos(buffer, size, offset); +} + +FX_BOOL CFX_CRTFileStream::Flush() { + return m_pFile->Flush(); +} + #ifdef PDF_ENABLE_XFA IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) { if (wsPath.GetLength() == 0) -- cgit v1.2.3