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_memory.h" | 10 #include "fx_memory.h" |
11 #include "fx_string.h" | 11 #include "fx_string.h" |
12 | 12 |
13 void* FX_OpenFolder(FX_LPCSTR path); | 13 void* FX_OpenFolder(const FX_CHAR* path); |
14 void* FX_OpenFolder(FX_LPCWSTR path); | 14 void* FX_OpenFolder(const FX_WCHAR* path); |
15 FX_BOOL FX_GetNextFile(void* handle, CFX_ByteString& filename, FX_BOOL& bFolder)
; | 15 FX_BOOL FX_GetNextFile(void* handle, CFX_ByteString& filename, FX_BOOL& bFolder)
; |
16 FX_BOOL FX_GetNextFile(void* handle, CFX_WideString& filename, FX_BOOL& bFolder)
; | 16 FX_BOOL FX_GetNextFile(void* handle, CFX_WideString& filename, FX_BOOL& bFolder)
; |
17 void FX_CloseFolder(void* handle); | 17 void FX_CloseFolder(void* handle); |
18 FX_WCHAR FX_GetFolderSeparator(); | 18 FX_WCHAR FX_GetFolderSeparator(); |
19 typedef struct FX_HFILE_ { | 19 typedef struct FX_HFILE_ { |
20 FX_LPVOID pData; | 20 void* pData; |
21 }* FX_HFILE; | 21 }* FX_HFILE; |
22 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 22 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
23 #define FX_FILESIZE int32_t | 23 #define FX_FILESIZE int32_t |
24 #else | 24 #else |
25 #include <fcntl.h> | 25 #include <fcntl.h> |
26 #include <unistd.h> | 26 #include <unistd.h> |
27 #include <sys/stat.h> | 27 #include <sys/stat.h> |
28 #ifndef O_BINARY | 28 #ifndef O_BINARY |
29 #define O_BINARY 0 | 29 #define O_BINARY 0 |
30 #endif | 30 #endif |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 virtual FX_FILESIZE GetSize() = 0; | 81 virtual FX_FILESIZE GetSize() = 0; |
82 | 82 |
83 virtual FX_BOOL Flush() = 0; | 83 virtual FX_BOOL Flush() = 0; |
84 | 84 |
85 virtual FX_BOOL WriteBlock(const void* pData, FX_FILESIZ
E offset, size_t size) = 0; | 85 virtual FX_BOOL WriteBlock(const void* pData, FX_FILESIZ
E offset, size_t size) = 0; |
86 virtual FX_BOOL WriteBlock(const void* pData, size_t siz
e) | 86 virtual FX_BOOL WriteBlock(const void* pData, size_t siz
e) |
87 { | 87 { |
88 return WriteBlock(pData, GetSize(), size); | 88 return WriteBlock(pData, GetSize(), size); |
89 } | 89 } |
90 }; | 90 }; |
91 IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename); | 91 IFX_FileWrite* FX_CreateFileWrite(const FX_CHAR* filename); |
92 IFX_FileWrite* FX_CreateFileWrite(FX_LPCWSTR filename); | 92 IFX_FileWrite* FX_CreateFileWrite(const FX_WCHAR* filename); |
93 class IFX_StreamRead | 93 class IFX_StreamRead |
94 { | 94 { |
95 public: | 95 public: |
96 virtual ~IFX_StreamRead() { } | 96 virtual ~IFX_StreamRead() { } |
97 | 97 |
98 virtual void Release() = 0; | 98 virtual void Release() = 0; |
99 | 99 |
100 virtual FX_BOOL IsEOF() = 0; | 100 virtual FX_BOOL IsEOF() = 0; |
101 | 101 |
102 virtual FX_FILESIZE GetPosition() = 0; | 102 virtual FX_FILESIZE GetPosition() = 0; |
(...skipping 24 matching lines...) Expand all Loading... |
127 | 127 |
128 virtual void ClearRange() {} | 128 virtual void ClearRange() {} |
129 | 129 |
130 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offs
et, size_t size) = 0; | 130 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offs
et, size_t size) = 0; |
131 | 131 |
132 virtual size_t ReadBlock(void* buffer, size_t size) | 132 virtual size_t ReadBlock(void* buffer, size_t size) |
133 { | 133 { |
134 return 0; | 134 return 0; |
135 } | 135 } |
136 }; | 136 }; |
137 IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename); | 137 IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename); |
138 IFX_FileRead* FX_CreateFileRead(FX_LPCWSTR filename); | 138 IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename); |
139 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite | 139 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite |
140 { | 140 { |
141 public: | 141 public: |
142 | 142 |
143 virtual IFX_FileStream* Retain() = 0; | 143 virtual IFX_FileStream* Retain() = 0; |
144 | 144 |
145 virtual void Release() = 0; | 145 virtual void Release() = 0; |
146 | 146 |
147 virtual FX_FILESIZE GetSize() = 0; | 147 virtual FX_FILESIZE GetSize() = 0; |
148 | 148 |
149 virtual FX_BOOL IsEOF() = 0; | 149 virtual FX_BOOL IsEOF() = 0; |
150 | 150 |
151 virtual FX_FILESIZE GetPosition() = 0; | 151 virtual FX_FILESIZE GetPosition() = 0; |
152 | 152 |
153 virtual FX_BOOL ReadBlock(void* buffer, FX_FILES
IZE offset, size_t size) = 0; | 153 virtual FX_BOOL ReadBlock(void* buffer, FX_FILES
IZE offset, size_t size) = 0; |
154 | 154 |
155 virtual size_t ReadBlock(void* buffer, size_t s
ize) = 0; | 155 virtual size_t ReadBlock(void* buffer, size_t s
ize) = 0; |
156 | 156 |
157 virtual FX_BOOL WriteBlock(const void* buffer, F
X_FILESIZE offset, size_t size) = 0; | 157 virtual FX_BOOL WriteBlock(const void* buffer, F
X_FILESIZE offset, size_t size) = 0; |
158 virtual FX_BOOL WriteBlock(const void* buffer, s
ize_t size) | 158 virtual FX_BOOL WriteBlock(const void* buffer, s
ize_t size) |
159 { | 159 { |
160 return WriteBlock(buffer, GetSize(), size); | 160 return WriteBlock(buffer, GetSize(), size); |
161 } | 161 } |
162 | 162 |
163 virtual FX_BOOL Flush() = 0; | 163 virtual FX_BOOL Flush() = 0; |
164 }; | 164 }; |
165 IFX_FileStream*»» FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes
); | 165 IFX_FileStream*»» FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dw
Modes); |
166 IFX_FileStream*»» FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwMode
s); | 166 IFX_FileStream*»» FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD d
wModes); |
167 class IFX_MemoryStream : public IFX_FileStream | 167 class IFX_MemoryStream : public IFX_FileStream |
168 { | 168 { |
169 public: | 169 public: |
170 | 170 |
171 virtual FX_BOOL IsConsecutive() const = 0; | 171 virtual FX_BOOL IsConsecutive() const = 0; |
172 | 172 |
173 virtual void EstimateSize(size_t nInitSize, size_t nG
rowSize) = 0; | 173 virtual void EstimateSize(size_t nInitSize, size_t nG
rowSize) = 0; |
174 | 174 |
175 virtual FX_LPBYTE» » GetBuffer() const = 0; | 175 virtual uint8_t*» » GetBuffer() const = 0; |
176 | 176 |
177 virtual void» » » AttachBuffer(FX_LPBYTE pBuffer, size_t n
Size, FX_BOOL bTakeOver = FALSE) = 0; | 177 virtual void» » » AttachBuffer(uint8_t* pBuffer, size_t nS
ize, FX_BOOL bTakeOver = FALSE) = 0; |
178 | 178 |
179 virtual void DetachBuffer() = 0; | 179 virtual void DetachBuffer() = 0; |
180 }; | 180 }; |
181 IFX_MemoryStream*» FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t nSize, F
X_BOOL bTakeOver = FALSE); | 181 IFX_MemoryStream*» FX_CreateMemoryStream(uint8_t* pBuffer, size_t nSize, FX
_BOOL bTakeOver = FALSE); |
182 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE); | 182 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE); |
183 class IFX_BufferRead : public IFX_StreamRead | 183 class IFX_BufferRead : public IFX_StreamRead |
184 { | 184 { |
185 public: | 185 public: |
186 | 186 |
187 virtual void Release() = 0; | 187 virtual void Release() = 0; |
188 | 188 |
189 virtual FX_BOOL IsEOF() = 0; | 189 virtual FX_BOOL IsEOF() = 0; |
190 | 190 |
191 virtual FX_FILESIZE GetPosition() = 0; | 191 virtual FX_FILESIZE GetPosition() = 0; |
192 | 192 |
193 virtual size_t ReadBlock(void* buffer, size_t size) = 0
; | 193 virtual size_t ReadBlock(void* buffer, size_t size) = 0
; |
194 | 194 |
195 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE)
= 0; | 195 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE)
= 0; |
196 | 196 |
197 virtual FX_LPCBYTE» » GetBlockBuffer() = 0; | 197 virtual const uint8_t*» » GetBlockBuffer() = 0; |
198 | 198 |
199 virtual size_t GetBlockSize() = 0; | 199 virtual size_t GetBlockSize() = 0; |
200 | 200 |
201 virtual FX_FILESIZE GetBlockOffset() = 0; | 201 virtual FX_FILESIZE GetBlockOffset() = 0; |
202 }; | 202 }; |
203 | 203 |
204 #endif // CORE_INCLUDE_FXCRT_FX_STREAM_H_ | 204 #endif // CORE_INCLUDE_FXCRT_FX_STREAM_H_ |
OLD | NEW |