| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_INCLUDE_FXCRT_FX_STREAM_H_ | 7 #ifndef CORE_INCLUDE_FXCRT_FX_STREAM_H_ |
| 8 #define CORE_INCLUDE_FXCRT_FX_STREAM_H_ | 8 #define CORE_INCLUDE_FXCRT_FX_STREAM_H_ |
| 9 | 9 |
| 10 #include "fx_string.h" | 10 #include "fx_string.h" |
| 11 | 11 |
| 12 void* FX_OpenFolder(const FX_CHAR* path); | 12 void* FX_OpenFolder(const FX_CHAR* path); |
| 13 void* FX_OpenFolder(const FX_WCHAR* path); | 13 void* FX_OpenFolder(const FX_WCHAR* path); |
| 14 FX_BOOL FX_GetNextFile(void* handle, CFX_ByteString& filename, FX_BOOL& bFolder)
; | 14 bool FX_GetNextFile(void* handle, CFX_ByteString& filename, bool& bFolder); |
| 15 FX_BOOL FX_GetNextFile(void* handle, CFX_WideString& filename, FX_BOOL& bFolder)
; | 15 bool FX_GetNextFile(void* handle, CFX_WideString& filename, bool& bFolder); |
| 16 void FX_CloseFolder(void* handle); | 16 void FX_CloseFolder(void* handle); |
| 17 FX_WCHAR FX_GetFolderSeparator(); | 17 FX_WCHAR FX_GetFolderSeparator(); |
| 18 typedef struct FX_HFILE_ { | 18 typedef struct FX_HFILE_ { |
| 19 void* pData; | 19 void* pData; |
| 20 }* FX_HFILE; | 20 }* FX_HFILE; |
| 21 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 21 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 22 #define FX_FILESIZE int32_t | 22 #define FX_FILESIZE int32_t |
| 23 #else | 23 #else |
| 24 #include <fcntl.h> | 24 #include <fcntl.h> |
| 25 #include <unistd.h> | 25 #include <unistd.h> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 46 FX_HFILE FX_File_Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode); | 46 FX_HFILE FX_File_Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode); |
| 47 FX_HFILE FX_File_Open(const CFX_WideStringC& fileName, FX_DWORD dwMode); | 47 FX_HFILE FX_File_Open(const CFX_WideStringC& fileName, FX_DWORD dwMode); |
| 48 void FX_File_Close(FX_HFILE hFile); | 48 void FX_File_Close(FX_HFILE hFile); |
| 49 FX_FILESIZE FX_File_GetSize(FX_HFILE hFile); | 49 FX_FILESIZE FX_File_GetSize(FX_HFILE hFile); |
| 50 FX_FILESIZE FX_File_GetPosition(FX_HFILE hFile); | 50 FX_FILESIZE FX_File_GetPosition(FX_HFILE hFile); |
| 51 FX_FILESIZE FX_File_SetPosition(FX_HFILE hFile, FX_FILESIZE pos); | 51 FX_FILESIZE FX_File_SetPosition(FX_HFILE hFile, FX_FILESIZE pos); |
| 52 size_t FX_File_Read(FX_HFILE hFile, void* pBuffer, size_t szBuffer); | 52 size_t FX_File_Read(FX_HFILE hFile, void* pBuffer, size_t szBuffer); |
| 53 size_t FX_File_ReadPos(FX_HFILE hFile, void* pBuffer, size_t szBuffer,
FX_FILESIZE pos); | 53 size_t FX_File_ReadPos(FX_HFILE hFile, void* pBuffer, size_t szBuffer,
FX_FILESIZE pos); |
| 54 size_t FX_File_Write(FX_HFILE hFile, const void* pBuffer, size_t szBuff
er); | 54 size_t FX_File_Write(FX_HFILE hFile, const void* pBuffer, size_t szBuff
er); |
| 55 size_t FX_File_WritePos(FX_HFILE hFile, const void* pBuffer, size_t szB
uffer, FX_FILESIZE pos); | 55 size_t FX_File_WritePos(FX_HFILE hFile, const void* pBuffer, size_t szB
uffer, FX_FILESIZE pos); |
| 56 FX_BOOL»» FX_File_Flush(FX_HFILE hFile); | 56 bool» » FX_File_Flush(FX_HFILE hFile); |
| 57 FX_BOOL»» FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile); | 57 bool» » FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile); |
| 58 FX_BOOL»» FX_File_Exist(const CFX_ByteStringC& fileName); | 58 bool» » FX_File_Exist(const CFX_ByteStringC& fileName); |
| 59 FX_BOOL»» FX_File_Exist(const CFX_WideStringC& fileName); | 59 bool» » FX_File_Exist(const CFX_WideStringC& fileName); |
| 60 FX_BOOL»» FX_File_Delete(const CFX_ByteStringC& fileName); | 60 bool» » FX_File_Delete(const CFX_ByteStringC& fileName); |
| 61 FX_BOOL»» FX_File_Delete(const CFX_WideStringC& fileName); | 61 bool» » FX_File_Delete(const CFX_WideStringC& fileName); |
| 62 FX_BOOL»» FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteS
tringC& fileNameDst); | 62 bool» » FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteS
tringC& fileNameDst); |
| 63 FX_BOOL»» FX_File_Copy(const CFX_WideStringC& fileNameSrc, const CFX_WideS
tringC& fileNameDst); | 63 bool» » FX_File_Copy(const CFX_WideStringC& fileNameSrc, const CFX_WideS
tringC& fileNameDst); |
| 64 FX_BOOL»» FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteS
tringC& fileNameDst); | 64 bool» » FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteS
tringC& fileNameDst); |
| 65 FX_BOOL»» FX_File_Move(const CFX_WideStringC& fileNameSrc, const CFX_WideS
tringC& fileNameDst); | 65 bool» » FX_File_Move(const CFX_WideStringC& fileNameSrc, const CFX_WideS
tringC& fileNameDst); |
| 66 class IFX_StreamWrite | 66 class IFX_StreamWrite |
| 67 { | 67 { |
| 68 public: | 68 public: |
| 69 virtual ~IFX_StreamWrite() { } | 69 virtual ~IFX_StreamWrite() { } |
| 70 virtual void Release() = 0; | 70 virtual void Release() = 0; |
| 71 | 71 |
| 72 virtual» FX_BOOL»» WriteBlock(const void* pData, size_t size) = 0; | 72 virtual» bool» » WriteBlock(const void* pData, size_t size) = 0; |
| 73 }; | 73 }; |
| 74 class IFX_FileWrite : public IFX_StreamWrite | 74 class IFX_FileWrite : public IFX_StreamWrite |
| 75 { | 75 { |
| 76 public: | 76 public: |
| 77 | 77 |
| 78 virtual void Release() = 0; | 78 virtual void Release() = 0; |
| 79 | 79 |
| 80 virtual FX_FILESIZE GetSize() = 0; | 80 virtual FX_FILESIZE GetSize() = 0; |
| 81 | 81 |
| 82 virtual FX_BOOL» » » Flush() = 0; | 82 virtual bool» » » Flush() = 0; |
| 83 | 83 |
| 84 virtual» FX_BOOL»» » WriteBlock(const void* pData, FX_FILESIZ
E offset, size_t size) = 0; | 84 virtual» bool» » » WriteBlock(const void* pData, FX_FILESIZ
E offset, size_t size) = 0; |
| 85 virtual» FX_BOOL»» » WriteBlock(const void* pData, size_t siz
e) | 85 virtual» bool» » » WriteBlock(const void* pData, size_t siz
e) |
| 86 { | 86 { |
| 87 return WriteBlock(pData, GetSize(), size); | 87 return WriteBlock(pData, GetSize(), size); |
| 88 } | 88 } |
| 89 }; | 89 }; |
| 90 IFX_FileWrite* FX_CreateFileWrite(const FX_CHAR* filename); | 90 IFX_FileWrite* FX_CreateFileWrite(const FX_CHAR* filename); |
| 91 IFX_FileWrite* FX_CreateFileWrite(const FX_WCHAR* filename); | 91 IFX_FileWrite* FX_CreateFileWrite(const FX_WCHAR* filename); |
| 92 class IFX_StreamRead | 92 class IFX_StreamRead |
| 93 { | 93 { |
| 94 public: | 94 public: |
| 95 virtual ~IFX_StreamRead() { } | 95 virtual ~IFX_StreamRead() { } |
| 96 | 96 |
| 97 virtual void Release() = 0; | 97 virtual void Release() = 0; |
| 98 | 98 |
| 99 virtual FX_BOOL» » » IsEOF() = 0; | 99 virtual bool» » » IsEOF() = 0; |
| 100 | 100 |
| 101 virtual FX_FILESIZE GetPosition() = 0; | 101 virtual FX_FILESIZE GetPosition() = 0; |
| 102 | 102 |
| 103 virtual size_t ReadBlock(void* buffer, size_t size) = 0
; | 103 virtual size_t ReadBlock(void* buffer, size_t size) = 0
; |
| 104 }; | 104 }; |
| 105 class IFX_FileRead : IFX_StreamRead | 105 class IFX_FileRead : IFX_StreamRead |
| 106 { | 106 { |
| 107 public: | 107 public: |
| 108 virtual void Release() = 0; | 108 virtual void Release() = 0; |
| 109 | 109 |
| 110 virtual FX_FILESIZE GetSize() = 0; | 110 virtual FX_FILESIZE GetSize() = 0; |
| 111 | 111 |
| 112 virtual FX_BOOL» » » IsEOF() | 112 virtual bool» » » IsEOF() |
| 113 { | 113 { |
| 114 return FALSE; | 114 return false; |
| 115 } | 115 } |
| 116 | 116 |
| 117 virtual FX_FILESIZE GetPosition() | 117 virtual FX_FILESIZE GetPosition() |
| 118 { | 118 { |
| 119 return 0; | 119 return 0; |
| 120 } | 120 } |
| 121 | 121 |
| 122 virtual FX_BOOL» » » SetRange(FX_FILESIZE offset, FX_FILESIZE
size) | 122 virtual bool» » » SetRange(FX_FILESIZE offset, FX_FILESIZE
size) |
| 123 { | 123 { |
| 124 return FALSE; | 124 return false; |
| 125 } | 125 } |
| 126 | 126 |
| 127 virtual void ClearRange() {} | 127 virtual void ClearRange() {} |
| 128 | 128 |
| 129 virtual FX_BOOL» » » ReadBlock(void* buffer, FX_FILESIZE offs
et, size_t size) = 0; | 129 virtual bool» » » ReadBlock(void* buffer, FX_FILESIZE offs
et, size_t size) = 0; |
| 130 | 130 |
| 131 virtual size_t ReadBlock(void* buffer, size_t size) | 131 virtual size_t ReadBlock(void* buffer, size_t size) |
| 132 { | 132 { |
| 133 return 0; | 133 return 0; |
| 134 } | 134 } |
| 135 }; | 135 }; |
| 136 IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename); | 136 IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename); |
| 137 IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename); | 137 IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename); |
| 138 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite | 138 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite |
| 139 { | 139 { |
| 140 public: | 140 public: |
| 141 | 141 |
| 142 virtual IFX_FileStream* Retain() = 0; | 142 virtual IFX_FileStream* Retain() = 0; |
| 143 | 143 |
| 144 virtual void Release() = 0; | 144 virtual void Release() = 0; |
| 145 | 145 |
| 146 virtual FX_FILESIZE GetSize() = 0; | 146 virtual FX_FILESIZE GetSize() = 0; |
| 147 | 147 |
| 148 virtual FX_BOOL» » » » IsEOF() = 0; | 148 virtual bool» » » » IsEOF() = 0; |
| 149 | 149 |
| 150 virtual FX_FILESIZE GetPosition() = 0; | 150 virtual FX_FILESIZE GetPosition() = 0; |
| 151 | 151 |
| 152 virtual FX_BOOL» » » » ReadBlock(void* buffer, FX_FILES
IZE offset, size_t size) = 0; | 152 virtual bool» » » » ReadBlock(void* buffer, FX_FILES
IZE offset, size_t size) = 0; |
| 153 | 153 |
| 154 virtual size_t ReadBlock(void* buffer, size_t s
ize) = 0; | 154 virtual size_t ReadBlock(void* buffer, size_t s
ize) = 0; |
| 155 | 155 |
| 156 virtual» FX_BOOL»» » » WriteBlock(const void* buffer, F
X_FILESIZE offset, size_t size) = 0; | 156 virtual» bool» » » » WriteBlock(const void* buffer, F
X_FILESIZE offset, size_t size) = 0; |
| 157 virtual» FX_BOOL»» » » WriteBlock(const void* buffer, s
ize_t size) | 157 virtual» bool» » » » WriteBlock(const void* buffer, s
ize_t size) |
| 158 { | 158 { |
| 159 return WriteBlock(buffer, GetSize(), size); | 159 return WriteBlock(buffer, GetSize(), size); |
| 160 } | 160 } |
| 161 | 161 |
| 162 virtual FX_BOOL» » » » Flush() = 0; | 162 virtual bool» » » » Flush() = 0; |
| 163 }; | 163 }; |
| 164 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dw
Modes); | 164 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dw
Modes); |
| 165 IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD d
wModes); | 165 IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD d
wModes); |
| 166 class IFX_MemoryStream : public IFX_FileStream | 166 class IFX_MemoryStream : public IFX_FileStream |
| 167 { | 167 { |
| 168 public: | 168 public: |
| 169 | 169 |
| 170 virtual FX_BOOL» » » IsConsecutive() const = 0; | 170 virtual bool» » » IsConsecutive() const = 0; |
| 171 | 171 |
| 172 virtual void EstimateSize(size_t nInitSize, size_t nG
rowSize) = 0; | 172 virtual void EstimateSize(size_t nInitSize, size_t nG
rowSize) = 0; |
| 173 | 173 |
| 174 virtual uint8_t* GetBuffer() const = 0; | 174 virtual uint8_t* GetBuffer() const = 0; |
| 175 | 175 |
| 176 virtual void» » » AttachBuffer(uint8_t* pBuffer, size_t nS
ize, FX_BOOL bTakeOver = FALSE) = 0; | 176 virtual void» » » AttachBuffer(uint8_t* pBuffer, size_t nS
ize, bool bTakeOver = false) = 0; |
| 177 | 177 |
| 178 virtual void DetachBuffer() = 0; | 178 virtual void DetachBuffer() = 0; |
| 179 }; | 179 }; |
| 180 IFX_MemoryStream*» FX_CreateMemoryStream(uint8_t* pBuffer, size_t nSize, FX
_BOOL bTakeOver = FALSE); | 180 IFX_MemoryStream*» FX_CreateMemoryStream(uint8_t* pBuffer, size_t nSize, bo
ol bTakeOver = false); |
| 181 IFX_MemoryStream*» FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE); | 181 IFX_MemoryStream*» FX_CreateMemoryStream(bool bConsecutive = false); |
| 182 class IFX_BufferRead : public IFX_StreamRead | 182 class IFX_BufferRead : public IFX_StreamRead |
| 183 { | 183 { |
| 184 public: | 184 public: |
| 185 | 185 |
| 186 virtual void Release() = 0; | 186 virtual void Release() = 0; |
| 187 | 187 |
| 188 virtual FX_BOOL» » » IsEOF() = 0; | 188 virtual bool» » » IsEOF() = 0; |
| 189 | 189 |
| 190 virtual FX_FILESIZE GetPosition() = 0; | 190 virtual FX_FILESIZE GetPosition() = 0; |
| 191 | 191 |
| 192 virtual size_t ReadBlock(void* buffer, size_t size) = 0
; | 192 virtual size_t ReadBlock(void* buffer, size_t size) = 0
; |
| 193 | 193 |
| 194 virtual FX_BOOL» » » ReadNextBlock(FX_BOOL bRestart = FALSE)
= 0; | 194 virtual bool» » » ReadNextBlock(bool bRestart = false) = 0
; |
| 195 | 195 |
| 196 virtual const uint8_t* GetBlockBuffer() = 0; | 196 virtual const uint8_t* GetBlockBuffer() = 0; |
| 197 | 197 |
| 198 virtual size_t GetBlockSize() = 0; | 198 virtual size_t GetBlockSize() = 0; |
| 199 | 199 |
| 200 virtual FX_FILESIZE GetBlockOffset() = 0; | 200 virtual FX_FILESIZE GetBlockOffset() = 0; |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 #endif // CORE_INCLUDE_FXCRT_FX_STREAM_H_ | 203 #endif // CORE_INCLUDE_FXCRT_FX_STREAM_H_ |
| OLD | NEW |