summaryrefslogtreecommitdiff
path: root/core/src/fxcrt/fx_extension.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fxcrt/fx_extension.cpp')
-rw-r--r--core/src/fxcrt/fx_extension.cpp53
1 files changed, 53 insertions, 0 deletions
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 <ctime>
#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)