Foxit PDF SDK

fx_stream.h
Go to the documentation of this file.
1
15 //<<<+++OPENSOURCE
16 //<<<+++OPENSOURCE_LICENSE
17 //<<<+++OPENSOURCE_BEGIN LIC==FOXIT||LIC==GOOGLE
18
24 //<<<+++OPENSOURCE_MUST_BEGIN
25 #ifndef _FX_STREAM_H_
26 #define _FX_STREAM_H_
27
28 #ifndef _FX_MEMORY_H_
29 #include "fx_memory.h"
30 #endif
31 //<<<+++OPENSOURCE_MUST_END
32
33 //*****************************************************************************
34 //* Folder access
35 //*****************************************************************************
36 #if !defined(_FPDFAPI_MINI_) || (defined(_WIN32) && !defined(_FX_NO_WINDOWS_)) || _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || _FX_OS_ == _FX_ANDROID_ || _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
37
44 void* FX_OpenFolder(FX_LPCSTR path);
52 void* FX_OpenFolder(FX_LPCWSTR path);
53
64 FX_BOOL FX_GetNextFile(void* handle, CFX_ByteString& filename, FX_BOOL& bFolder, FX_LPCSTR absPath=NULL);
75 FX_BOOL FX_GetNextFile(void* handle, CFX_WideString& filename, FX_BOOL& bFolder, FX_LPCSTR absPath=NULL);
76
84 void FX_CloseFolder(void* handle);
85
91 FX_WCHAR FX_GetFolderSeparator();
92
93 #endif
94
95 #if _FX_OS_ != _FX_EMBEDDED_
96 //<<<+++OPENSOURCE_BEGIN LIC==FOXIT
104 FX_BOOL FX_CreateFolder(FX_LPCSTR path);
112 FX_BOOL FX_CreateFolder(FX_LPCWSTR path);
113
121 FX_BOOL FX_DeleteFolder(FX_LPCSTR path);
129 FX_BOOL FX_DeleteFolder(FX_LPCWSTR path);
130
138 FX_BOOL FX_IsFilePathExist(FX_LPCWSTR path);
139 //<<<+++OPENSOURCE_END
140 #endif
141
142 //*****************************************************************************
143 //* File access
144 //*****************************************************************************
146 FX_DEFINEHANDLE(FX_HFILE)
147
148 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
149 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_
150 #if defined(_FX_LARGEFILE_SUPPORT_)
151
152 #define _FX_LARGEFILE_USED_
153
155 #define FX_FILESIZE FX_INT64
156 #define FX_GETBYTEOFFSET32(a) ((FX_BYTE)((a>>16)>>16))
157 #define FX_GETBYTEOFFSET40(a) ((FX_BYTE)(((a>>16)>>16)>>8))
158 #define FX_GETBYTEOFFSET48(a) ((FX_BYTE)(((a>>16)>>16)>>16))
159 #define FX_GETBYTEOFFSET56(a) ((FX_BYTE)((((a>>16)>>16)>>16)>>8))
160 #else
161
162 #define FX_FILESIZE FX_INT32
163 #define FX_GETBYTEOFFSET32(a) 0
164 #define FX_GETBYTEOFFSET40(a) 0
165 #define FX_GETBYTEOFFSET48(a) 0
166 #define FX_GETBYTEOFFSET56(a) 0
167 #endif
168 #elif _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_ANDROID_ || _FX_OS_==_FX_LINUX_EMBEDDED_
169 #if defined(_FX_LARGEFILE_SUPPORT_)
170
171 #define _FX_LARGEFILE_USED_
172
173 #ifndef _LARGEFILE_SOURCE
174 #define _LARGEFILE_SOURCE
175 #endif
176 #ifndef _LARGEFILE64_SOURCE
177 #define _LARGEFILE64_SOURCE
178 #endif
179 #endif
180 #if defined(_FX_LARGEFILE_SUPPORT_)
181 #define FX_GETBYTEOFFSET32(a) ((FX_BYTE)((a>>16)>>16))
182 #define FX_GETBYTEOFFSET40(a) ((FX_BYTE)(((a>>16)>>16)>>8))
183 #define FX_GETBYTEOFFSET48(a) ((FX_BYTE)(((a>>16)>>16)>>16))
184 #define FX_GETBYTEOFFSET56(a) ((FX_BYTE)((((a>>16)>>16)>>16)>>8))
185 #else
186 #define FX_GETBYTEOFFSET32(a) 0
187 #define FX_GETBYTEOFFSET40(a) 0
188 #define FX_GETBYTEOFFSET48(a) 0
189 #define FX_GETBYTEOFFSET56(a) 0
190 #endif
191 #include <fcntl.h>
192 #include <unistd.h>
193 #include <sys/stat.h>
194
195 #ifndef O_BINARY
196 #define O_BINARY 0
197 #endif
198 #ifndef O_LARGEFILE
199 #define O_LARGEFILE 0
200 #endif
201
203 #if defined(_FX_LARGEFILE_SUPPORT_)
204 #if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_LINUX_EMBEDDED_ || _FX_OS_ == _FX_ANDROID_
205 // mac and bsd are always 64 bit. use off_t
206 // linux and android uses off64_t
207 #ifndef _CHROME_PNACL_
208 #define _FX_USE_OFF64_T_
209 #endif
210 #endif
211 #endif
212 #if defined(_FX_USE_OFF64_T_)
213 #define FX_FILESIZE off64_t
214 #elif _FX_OS_ == _FX_LINUX_EMBEDDED_
215 #define FX_FILESIZE FX_INT32
216 #else
217 #ifndef _CHROME_PNACL_
218 #define FX_FILESIZE off_t
219 #else
220 #define FX_FILESIZE FX_INT32
221 #endif
222 #endif
223 #else //do not support large file.
224
225 #define FX_FILESIZE FX_INT32
226 #define FX_GETBYTEOFFSET32(a) 0
227 #define FX_GETBYTEOFFSET40(a) 0
228 #define FX_GETBYTEOFFSET48(a) 0
229 #define FX_GETBYTEOFFSET56(a) 0
230 #endif
231 //<<<+++OPENSOURCE_MUST_END
232
233 #define FX_GETBYTEOFFSET24(a) ((FX_BYTE)(a>>24))
234 #define FX_GETBYTEOFFSET16(a) ((FX_BYTE)(a>>16))
235 #define FX_GETBYTEOFFSET8(a) ((FX_BYTE)(a>>8))
236 #define FX_GETBYTEOFFSET0(a) ((FX_BYTE)(a))
237
243 #define FX_FILEMODE_Write 0
244
245 #define FX_FILEMODE_ReadOnly 1
246
247 #define FX_FILEMODE_Truncate 2 //
248
260 FX_HFILE FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocator = NULL);
271 FX_HFILE FX_File_Open(FX_WSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocator = NULL);
280 void FX_File_Close(FX_HFILE hFile, IFX_Allocator* pAllocator = NULL);
281 //<<<+++OPENSOURCE_END
282
290 FX_FILESIZE FX_File_GetSize(FX_HFILE hFile);
298 FX_FILESIZE FX_File_GetPosition(FX_HFILE hFile);
307 FX_FILESIZE FX_File_SetPosition(FX_HFILE hFile, FX_FILESIZE pos);
317 size_t FX_File_Read(FX_HFILE hFile, void* pBuffer, size_t szBuffer);
328 size_t FX_File_ReadPos(FX_HFILE hFile, void* pBuffer, size_t szBuffer, FX_FILESIZE pos);
338 size_t FX_File_Write(FX_HFILE hFile, const void* pBuffer, size_t szBuffer);
349 size_t FX_File_WritePos(FX_HFILE hFile, const void* pBuffer, size_t szBuffer, FX_FILESIZE pos);
357 FX_BOOL FX_File_Flush(FX_HFILE hFile);
366 FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile);
367
375 FX_BOOL FX_File_Exist(FX_BSTR fileName);
383 FX_BOOL FX_File_Exist(FX_WSTR fileName);
391 FX_BOOL FX_File_Delete(FX_BSTR fileName);
399 FX_BOOL FX_File_Delete(FX_WSTR fileName);
408 FX_BOOL FX_File_Copy(FX_BSTR fileNameSrc, FX_BSTR fileNameDst);
417 FX_BOOL FX_File_Copy(FX_WSTR fileNameSrc, FX_WSTR fileNameDst);
426 FX_BOOL FX_File_Move(FX_BSTR fileNameSrc, FX_BSTR fileNameDst);
435 FX_BOOL FX_File_Move(FX_WSTR fileNameSrc, FX_WSTR fileNameDst);
436
437 //*****************************************************************************
438 //* IFX_StreamWrite/IFX_FileWrite
439 //*****************************************************************************
441 class IFX_StreamWrite
442 {
443 public:
445 virtual void Release() = 0;
446
455 virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0;
461 virtual FX_BOOL Flush() { return true; }
462
463 #if !defined(__EMSCRIPTEN__) && !defined(SWIGJAVA)
464 protected:
465 #endif
466 virtual ~IFX_StreamWrite() {}
467 };
468
470 class IFX_FileWrite : public IFX_StreamWrite
471 {
472 public:
474 virtual void Release() = 0;
475
481 virtual FX_FILESIZE GetSize() = 0;
487 virtual FX_BOOL Flush() = 0;
497 virtual FX_BOOL WriteBlock(const void* pData, FX_FILESIZE offset, size_t size) = 0;
506 virtual FX_BOOL WriteBlock(const void* pData, size_t size) {return WriteBlock(pData, GetSize(), size);}
507
508 #if !defined(__EMSCRIPTEN__) && !defined(SWIGJAVA)
509 protected:
510 #endif
511 virtual ~IFX_FileWrite() {}
512 };
513
523 IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL);
524
534 IFX_FileWrite* FX_CreateFileWrite(FX_LPCWSTR filename, IFX_Allocator* pAllocator = NULL);
535 //<<<+++OPENSOURCE_END
536
537 //*****************************************************************************
538 //* IFX_FileRead
539 //*****************************************************************************
541 class IFX_StreamRead
542 {
543 public:
549 virtual void Release() = 0;
550
556 virtual FX_BOOL IsEOF() = 0;
562 virtual FX_FILESIZE GetPosition() = 0;
571 virtual size_t ReadBlock(void* buffer, size_t size) = 0;
572
580 virtual FX_FILESIZE SetPosition(FX_FILESIZE pos) { FXSYS_assert(false && "Unsupport"); return -1; }
581
582 protected:
583 virtual ~IFX_StreamRead() {}
584 };
585
587 class IFX_FileRead : public IFX_StreamRead
588 {
589 public:
595 virtual void Release() = 0;
596
602 virtual FX_FILESIZE GetSize() = 0;
608 virtual FX_BOOL IsEOF() {return false;}
614 virtual FX_FILESIZE GetPosition() {return 0;}
623 virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size) {return false;}
629 virtual void ClearRange() {}
639 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
648 virtual size_t ReadBlock(void* buffer, size_t size) {return 0;}
649
657 virtual FX_FILESIZE SetPosition(FX_FILESIZE pos) { FXSYS_assert(false && "Unsupport"); return -1; }
658
659 #if !defined(__EMSCRIPTEN__) && !defined(SWIGJAVA)
660 protected:
661 #endif
662 virtual ~IFX_FileRead() {}
663 };
664
674 IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL);
675
685 IFX_FileRead* FX_CreateFileRead(FX_LPCWSTR filename, IFX_Allocator* pAllocator = NULL);
686 //<<<+++OPENSOURCE_END
687
688 //*****************************************************************************
689 //* IFX_FileStream
690 //*****************************************************************************
692 class IFX_FileStream
693 : public IFX_FileRead, public IFX_FileWrite
694 {
695 public:
701 virtual IFX_FileStream* Retain() = 0;
707 virtual void Release() = 0;
708
714 virtual FX_FILESIZE GetSize() = 0;
720 virtual FX_BOOL IsEOF() = 0;
726 virtual FX_FILESIZE GetPosition() = 0;
727
737 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
746 virtual size_t ReadBlock(void* buffer, size_t size) = 0;
747
757 virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) = 0;
766 virtual FX_BOOL WriteBlock(const void* buffer, size_t size) {return WriteBlock(buffer, GetSize(), size);}
767
773 virtual FX_BOOL Flush() = 0;
774
775 #if !defined(__EMSCRIPTEN__) && !defined(SWIGJAVA)
776 protected:
777 #endif
778 virtual ~IFX_FileStream() {}
779 };
780
791 IFX_FileStream* FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes, IFX_Allocator* pAllocator = NULL);
792
803 IFX_FileStream* FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwModes, IFX_Allocator* pAllocator = NULL);
804 //<<<+++OPENSOURCE_END
805
806 //*****************************************************************************
807 //* IFX_ChunkFileStream
808 //*****************************************************************************
810 class IFX_ChunkFileStream : public IFX_FileStream
811 {
812 public:
818 virtual void Release() = 0;
819
825 virtual FX_FILESIZE GetSize() = 0;
831 virtual FX_BOOL IsEOF() = 0;
837 virtual FX_FILESIZE GetPosition() = 0;
838
848 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
857 virtual size_t ReadBlock(void* buffer, size_t size) = 0;
858
868 virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) = 0;
877 virtual FX_BOOL WriteBlock(const void* buffer, size_t size)
878 {
879 return WriteBlock(buffer, GetSize(), size);
880 }
881
887 virtual FX_BOOL Flush() = 0;
888
889 protected:
895 virtual IFX_FileStream* Retain() = 0;
896
897 virtual ~IFX_ChunkFileStream() {}
898
899 friend class CFX_ChunkFileStreamsManager;
900 };
901
902 //*****************************************************************************
903 //* CFX_ChunkFileStreamsManager
904 //*****************************************************************************
906 class CFX_ChunkFileStreamsManagerImpl;
907 class CFX_ChunkFileStreamsManager : public CFX_Object
908 {
909 public:
917 CFX_ChunkFileStreamsManager(IFX_FileStream* pFileStream, size_t nChunkSize = 1024);
924 ~CFX_ChunkFileStreamsManager();
925
932 IFX_ChunkFileStream* CreateChunkFileStream();
933
934 private:
935 std::shared_ptr<CFX_ChunkFileStreamsManagerImpl> m_pImpl;
936 };
937
938 //*****************************************************************************
939 //* IFX_FileAccess
940 //*****************************************************************************
942 class IFX_FileAccess
943 {
944 public:
950 virtual void Release() = 0;
951
957 virtual IFX_FileAccess* Retain() = 0;
965 virtual void GetPath(CFX_WideString& wsPath) = 0;
966
974 virtual IFX_FileStream* CreateFileStream(FX_DWORD dwModes) = 0;
975
976 protected:
977 virtual ~IFX_FileAccess() {}
978 };
979
989 IFX_FileAccess* FX_CreateDefaultFileAccess(FX_WSTR wsPath, IFX_Allocator* pAllocator = NULL);
990
991 class IFX_FileCollection
992 {
993 public:
994 virtual void Release() = 0;
995
996 virtual FX_POSITION GetStartPos() = 0;
997 virtual IFX_FileAccess* GetNextFile(FX_POSITION& pos) = 0;
998
999 protected:
1000 virtual ~IFX_FileCollection() {}
1001 };
1002 //<<<+++OPENSOURCE_END
1003
1004 //*****************************************************************************
1005 //* Memory stream
1006 //*****************************************************************************
1008 class IFX_MemoryStream : public IFX_FileStream
1009 {
1010 public:
1011 virtual ~IFX_MemoryStream() {}
1012
1018 virtual FX_BOOL IsConsecutive() const = 0;
1032 virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0;
1041 virtual FX_LPBYTE GetBuffer() const = 0;
1056 virtual void AttachBuffer(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = false) = 0;
1064 virtual void DetachBuffer() = 0;
1065 };
1079 IFX_MemoryStream* FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = false, IFX_Allocator* pAllocator = NULL);
1080
1092 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = false, IFX_Allocator* pAllocator = NULL);
1093 //<<<+++OPENSOURCE_END
1094
1095 //*****************************************************************************
1096 //* Buffer read stream
1097 //*****************************************************************************
1103 class IFX_BufferRead : public IFX_StreamRead
1104 {
1105 public:
1111 virtual void Release() = 0;
1112
1118 virtual FX_BOOL IsEOF() = 0;
1124 virtual FX_FILESIZE GetPosition() = 0;
1125
1134 virtual size_t ReadBlock(void* buffer, size_t size) = 0;
1135
1143 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = false) = 0;
1149 virtual FX_LPCBYTE GetBlockBuffer() = 0;
1155 virtual size_t GetBlockSize() = 0;
1163 virtual FX_FILESIZE GetBlockOffset() = 0;
1164
1165 protected:
1166 virtual ~IFX_BufferRead() {}
1167 };
1168
1169 //*****************************************************************************
1170 //* Cached file read
1171 //*****************************************************************************
1172 #define FX_FILECACHE_CHUNKSIZE 32768
1173 #define FX_FILECACHE_CHUNKCOUNT 64
1174
1176 class CFX_CachedFileRead : public IFX_FileStream, public CFX_Object
1177 {
1178 public:
1180 CFX_CachedFileRead();
1182 virtual ~CFX_CachedFileRead();
1183
1195 FX_BOOL Init(FX_INT32 nChunkSize, FX_INT32 nChunkCount, FX_LPVOID pBuffer, IFX_Allocator* pAllocator = NULL);
1204 FX_BOOL AttachFile(IFX_FileRead* pFile, FX_BOOL bTakeOver);
1213 FX_BOOL PreCache(FX_FILESIZE offset, FX_INT32 nCacheCount);
1214
1220 virtual FX_FILESIZE GetSize();
1226 virtual FX_BOOL IsEOF();
1232 virtual FX_FILESIZE GetPosition();
1233
1243 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size);
1252 virtual size_t ReadBlock(void* buffer, size_t size);
1253
1254 protected:
1255 FXMT_LOCKOBJECT_DEFINE(m_LockObj);
1256 FX_LPVOID m_pData;
1257 FX_DWORD m_dwCount;
1258
1259 /* @brief Create a shared instance. */
1260 virtual IFX_FileStream* Retain();
1261 /* @brief Called when to release everything */
1262 virtual void Release();
1264 virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) {return false;}
1266 virtual FX_BOOL Flush() {return false;}
1267 };
1268 //<<<+++OPENSOURCE_END
1269
1270 //<<<+++OPENSOURCE_MUST_BEGIN
1271 #endif // _FX_STREAM_H_
1272 //<<<+++OPENSOURCE_MUST_END
1273
1276 //<<<+++OPENSOURCE_END
FX_File_Truncate
FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_INT64 szFile)
Truncate file size.
IFX_FileWrite::WriteBlock
virtual FX_BOOL WriteBlock(const void *pData, size_t size)
Write a block data to the end.
Definition: fx_stream.h:506
FX_DWORD
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:726
IFX_FileWrite
File writing interface.
Definition: fx_stream.h:470
CFX_CachedFileRead::~CFX_CachedFileRead
virtual ~CFX_CachedFileRead()
Destructor.
IFX_ChunkFileStream
Chunk-based File stream interface, reading & writing.
Definition: fx_stream.h:810
IFX_BufferRead::Release
virtual void Release()=0
Called when to release the current instance.
CFX_CachedFileRead::Retain
virtual IFX_FileStream * Retain()
Create a shared instance.
IFX_MemoryStream::AttachBuffer
virtual void AttachBuffer(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver=false)=0
Attach a memory buffer.
CFX_CachedFileRead::AttachFile
FX_BOOL AttachFile(IFX_FileRead *pFile, FX_BOOL bTakeOver)
Attach a file read.
FX_CreateDefaultFileAccess
IFX_FileAccess * FX_CreateDefaultFileAccess(FX_WSTR wsPath, IFX_Allocator *pAllocator=0)
Create a CRT based file I/O interface.
FX_WCHAR
wchar_t FX_WCHAR
Compiler dependant Unicode character (16-bit for Microsoft Compiler, 32-bit for gcc).
Definition: fx_system.h:732
IFX_StreamWrite::WriteBlock
virtual FX_BOOL WriteBlock(const void *pData, size_t size)=0
Write a block data.
FX_File_Read
size_t FX_File_Read(FX_HFILE hFile, void *pBuffer, size_t szBuffer)
Read data from the current file accessing position.
IFX_StreamWrite::Release
virtual void Release()=0
Called when to release everything.
FX_File_WritePos
size_t FX_File_WritePos(FX_HFILE hFile, const void *pBuffer, size_t szBuffer, FX_INT64 pos)
Write data at specified position.
IFX_StreamRead
Stream reading interface.
Definition: fx_stream.h:541
IFX_ChunkFileStream::ReadBlock
virtual FX_BOOL ReadBlock(void *buffer, FX_INT64 offset, size_t size)=0
Read a data block from stream.
FX_CreateFolder
FX_BOOL FX_CreateFolder(FX_LPCSTR path)
Create new folder.
IFX_FileStream
File stream interface, reading & writing.
Definition: fx_stream.h:692
IFX_BufferRead::IsEOF
virtual FX_BOOL IsEOF()=0
Determine whether reach the end of stream.
IFX_FileAccess::Retain
virtual IFX_FileAccess * Retain()=0
Create a shared instance.
IFX_FileRead::IsEOF
virtual FX_BOOL IsEOF()
Determine whether reach the end of stream.
Definition: fx_stream.h:608
FX_DeleteFolder
FX_BOOL FX_DeleteFolder(FX_LPCSTR path)
Delete folder.
FX_CreateFileWrite
IFX_FileWrite * FX_CreateFileWrite(FX_LPCSTR filename, IFX_Allocator *pAllocator=0)
(Available only for platforms supporting CRT file access (fopen, ...)) Create a CRT based file writin...
FX_File_Copy
FX_BOOL FX_File_Copy(FX_BSTR fileNameSrc, FX_BSTR fileNameDst)
Copy file.
IFX_FileRead
File reading interface.
Definition: fx_stream.h:587
IFX_FileStream::WriteBlock
virtual FX_BOOL WriteBlock(const void *buffer, FX_INT64 offset, size_t size)=0
Write a block data into stream.
FX_File_SetPosition
FX_INT64 FX_File_SetPosition(FX_HFILE hFile, FX_INT64 pos)
Set the current file accessing position.
FX_File_GetPosition
FX_INT64 FX_File_GetPosition(FX_HFILE hFile)
Get the current file accessing position.
IFX_ChunkFileStream::GetPosition
virtual FX_INT64 GetPosition()=0
Get the current reading position in stream.
FX_File_Write
size_t FX_File_Write(FX_HFILE hFile, const void *pBuffer, size_t szBuffer)
Write data from the current file accessing position.
IFX_BufferRead
IFX_BufferRead stream provides an optimized approach to read stream data. Usually,...
Definition: fx_stream.h:1103
IFX_FileStream::Release
virtual void Release()=0
Destroy the current instance.
FX_CreateFileRead
IFX_FileRead * FX_CreateFileRead(FX_LPCSTR filename, IFX_Allocator *pAllocator=0)
(Available only for platforms supporting CRT file access) Create a CRT based file reading interface.
IFX_BufferRead::GetBlockSize
virtual size_t GetBlockSize()=0
Get the size of data in internal buffer.
IFX_StreamRead::SetPosition
virtual FX_INT64 SetPosition(FX_INT64 pos)
Set the current file accessing position.
Definition: fx_stream.h:580
IFX_StreamRead::ReadBlock
virtual size_t ReadBlock(void *buffer, size_t size)=0
Read data block from sequential stream.
IFX_ChunkFileStream::GetSize
virtual FX_INT64 GetSize()=0
Get the current stream size, in bytes.
IFX_StreamWrite
Stream writing interface.
Definition: fx_stream.h:441
FX_LPVOID
void * FX_LPVOID
Pointer to any type.
Definition: fx_system.h:654
IFX_FileAccess::GetPath
virtual void GetPath(CFX_WideString &wsPath)=0
Get current path string.
FX_DEFINEHANDLE
#define FX_DEFINEHANDLE(name)
Macro to define a handle type.
Definition: fx_system.h:772
IFX_MemoryStream::DetachBuffer
virtual void DetachBuffer()=0
Detach the current memory buffer.
IFX_ChunkFileStream::IsEOF
virtual FX_BOOL IsEOF()=0
Determine whether reach the end of stream.
FX_OpenFolder
void * FX_OpenFolder(FX_LPCSTR path)
Open a folder for reading.
CFX_CachedFileRead::ReadBlock
virtual FX_BOOL ReadBlock(void *buffer, FX_INT64 offset, size_t size)
Read a data block from the file.
CFX_CachedFileRead::Release
virtual void Release()
Destroy the current instance.
FX_POSITION
void * FX_POSITION
A value used to denote the position of an element in a collection.
Definition: fx_system.h:658
CFX_CachedFileRead::GetPosition
virtual FX_INT64 GetPosition()
Get the current reading position in stream.
FX_INT32
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:683
IFX_MemoryStream::IsConsecutive
virtual FX_BOOL IsConsecutive() const =0
Determine whether the current mode is consecutive or not.
IFX_FileStream::GetSize
virtual FX_INT64 GetSize()=0
Get the current stream size, in bytes.
FX_File_Exist
FX_BOOL FX_File_Exist(FX_BSTR fileName)
Determine whether a file exists or not.
IFX_FileRead::ReadBlock
virtual FX_BOOL ReadBlock(void *buffer, FX_INT64 offset, size_t size)=0
Read a data block from the file.
IFX_MemoryStream::EstimateSize
virtual void EstimateSize(size_t nInitSize, size_t nGrowSize)=0
Change initialize size and grow size.
CFX_ByteString
BYTE STRING CLASS.
Definition: fx_string.h:317
CFX_CachedFileRead::WriteBlock
virtual FX_BOOL WriteBlock(const void *buffer, FX_INT64 offset, size_t size)
Write a block data into stream. Unsupported for reading mode, return false directly.
Definition: fx_stream.h:1264
IFX_Allocator
Foxit allocator interface.
Definition: fx_memory.h:997
IFX_StreamWrite::Flush
virtual FX_BOOL Flush()
Flush stream data.
Definition: fx_stream.h:461
fx_memory.h
Header file for Memory management related definitions and classes.
IFX_FileAccess::Release
virtual void Release()=0
Destroy the current instance.
IFX_BufferRead::GetBlockOffset
virtual FX_INT64 GetBlockOffset()=0
Get the offset of data in internal buffer.
FX_LPCWSTR
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:736
CFX_CachedFileRead
Cached file read interface.
Definition: fx_stream.h:1176
IFX_FileWrite::GetSize
virtual FX_INT64 GetSize()=0
Get total size of the file.
IFX_FileWrite::Flush
virtual FX_BOOL Flush()=0
Flush internal buffer of the file.
FXSYS_assert
#define FXSYS_assert
Assertion.
Definition: fx_system.h:804
FX_File_Move
FX_BOOL FX_File_Move(FX_BSTR fileNameSrc, FX_BSTR fileNameDst)
Move file.
CFX_CachedFileRead::Flush
virtual FX_BOOL Flush()
Flush internal buffer. Unsupported for reading mode, return false directly.
Definition: fx_stream.h:1266
IFX_FileStream::WriteBlock
virtual FX_BOOL WriteBlock(const void *buffer, size_t size)
Write a block data to the end of current stream.
Definition: fx_stream.h:766
IFX_MemoryStream::GetBuffer
virtual FX_LPBYTE GetBuffer() const =0
Get the current memory buffer.
IFX_FileStream::IsEOF
virtual FX_BOOL IsEOF()=0
Determine whether reach the end of stream.
FX_LPCSTR
char const * FX_LPCSTR
Pointer to constant 8-bit Windows (ANSI) characters.
Definition: fx_system.h:705
IFX_FileRead::SetPosition
virtual FX_INT64 SetPosition(FX_INT64 pos)
Set the current file accessing position.
Definition: fx_stream.h:657
FX_FILESIZE
#define FX_FILESIZE
Support large file directly.
Definition: fx_stream.h:155
FX_LPCBYTE
unsigned char const * FX_LPCBYTE
Pointer to a constant FX_BYTE.
Definition: fx_system.h:669
IFX_FileStream::Retain
virtual IFX_FileStream * Retain()=0
Create a shared instance.
IFX_BufferRead::ReadBlock
virtual size_t ReadBlock(void *buffer, size_t size)=0
Read data block from sequential stream.
IFX_BufferRead::GetBlockBuffer
virtual FX_LPCBYTE GetBlockBuffer()=0
Get internal buffer of block data.
IFX_FileAccess::CreateFileStream
virtual IFX_FileStream * CreateFileStream(FX_DWORD dwModes)=0
Create IFX_FileStream to operate file.
IFX_MemoryStream
Memory stream interface.
Definition: fx_stream.h:1008
IFX_FileRead::ClearRange
virtual void ClearRange()
Clear accessing range set by function IFX_FileRead::SetRange.
Definition: fx_stream.h:629
CFX_CachedFileRead::PreCache
FX_BOOL PreCache(FX_INT64 offset, FX_INT32 nCacheCount)
Attach a file read.
IFX_BufferRead::ReadNextBlock
virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart=false)=0
Read the next block in sequential stream.
FX_BSTR
const typedef CFX_ByteStringC & FX_BSTR
A reference to a constant CFX_ByteStringC object.
Definition: fx_string.h:285
FX_File_GetSize
FX_INT64 FX_File_GetSize(FX_HFILE hFile)
Get file size.
FX_File_Open
FX_HFILE FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode, IFX_Allocator *pAllocator=0)
Open file with specified accessing mode.
FX_IsFilePathExist
FX_BOOL FX_IsFilePathExist(FX_LPCWSTR path)
Check if the path exists, including file path and folder path.
IFX_FileAccess
File access interface, open file.
Definition: fx_stream.h:942
CFX_CachedFileRead::Init
FX_BOOL Init(FX_INT32 nChunkSize, FX_INT32 nChunkCount, FX_LPVOID pBuffer, IFX_Allocator *pAllocator=0)
Initialize the chunk size and chunk count.
IFX_StreamRead::GetPosition
virtual FX_INT64 GetPosition()=0
Get the current reading position in stream.
IFX_FileStream::ReadBlock
virtual FX_BOOL ReadBlock(void *buffer, FX_INT64 offset, size_t size)=0
Read a data block from stream.
NULL
#define NULL
The null-pointer value.
Definition: fx_system.h:792
FX_File_ReadPos
size_t FX_File_ReadPos(FX_HFILE hFile, void *pBuffer, size_t szBuffer, FX_INT64 pos)
Read data from specified position.
IFX_StreamRead::IsEOF
virtual FX_BOOL IsEOF()=0
Determine whether reach the end of stream.
IFX_FileWrite::WriteBlock
virtual FX_BOOL WriteBlock(const void *pData, FX_INT64 offset, size_t size)=0
Write a block data.
FX_BOOL
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:691
FX_WSTR
const typedef CFX_WideStringC & FX_WSTR
Type definition for a reference to a constant CFX_WideStringC object.
Definition: fx_string.h:1426
FX_CreateFileStream
IFX_FileStream * FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes, IFX_Allocator *pAllocator=0)
(Available only for platforms supporting CRT file access) Create a CRT based file I/O interface.
FX_File_Close
void FX_File_Close(FX_HFILE hFile, IFX_Allocator *pAllocator=0)
Close file.
IFX_FileStream::GetPosition
virtual FX_INT64 GetPosition()=0
Get the current reading position in stream.
IFX_ChunkFileStream::WriteBlock
virtual FX_BOOL WriteBlock(const void *buffer, size_t size)
Write a block data to the end of current stream.
Definition: fx_stream.h:877
IFX_FileStream::Flush
virtual FX_BOOL Flush()=0
Flush internal buffer.
IFX_FileRead::GetSize
virtual FX_INT64 GetSize()=0
Get total size of the file.
FX_CloseFolder
void FX_CloseFolder(void *handle)
Close folder handle.
IFX_FileRead::SetRange
virtual FX_BOOL SetRange(FX_INT64 offset, FX_INT64 size)
Set accessing range.
Definition: fx_stream.h:623
FX_LPBYTE
unsigned char * FX_LPBYTE
Pointer to a FX_BYTE.
Definition: fx_system.h:667
FX_GetFolderSeparator
FX_WCHAR FX_GetFolderSeparator()
Get folder separator for the system. Most likely it's either /' or '\'.
FX_File_Delete
FX_BOOL FX_File_Delete(FX_BSTR fileName)
Delete file.
IFX_ChunkFileStream::Flush
virtual FX_BOOL Flush()=0
Flush internal buffer.
IFX_FileRead::GetPosition
virtual FX_INT64 GetPosition()
Get the current reading position in stream.
Definition: fx_stream.h:614
CFX_CachedFileRead::CFX_CachedFileRead
CFX_CachedFileRead()
Constructor.
IFX_StreamRead::Release
virtual void Release()=0
Called when to release everything.
CFX_CachedFileRead::IsEOF
virtual FX_BOOL IsEOF()
Determine whether reach the end of stream.
CFX_WideString
WIDE STRING CLASS.
Definition: fx_string.h:1461
IFX_BufferRead::GetPosition
virtual FX_INT64 GetPosition()=0
Get the current reading position in stream.
IFX_FileRead::Release
virtual void Release()=0
Called when to release everything.
FX_CreateMemoryStream
IFX_MemoryStream * FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver=false, IFX_Allocator *pAllocator=0)
Creates a stream object by a given memory buffer. This function creates a consecutive memory stream o...
CFX_CachedFileRead::GetSize
virtual FX_INT64 GetSize()
Get total size of the file.
IFX_ChunkFileStream::WriteBlock
virtual FX_BOOL WriteBlock(const void *buffer, FX_INT64 offset, size_t size)=0
Write a block data into stream.
IFX_ChunkFileStream::Retain
virtual IFX_FileStream * Retain()=0
Create a shared instance.
FX_File_Flush
FX_BOOL FX_File_Flush(FX_HFILE hFile)
Flush internal buffer if need.
IFX_FileWrite::Release
virtual void Release()=0
Called when to release everything.
IFX_ChunkFileStream::Release
virtual void Release()=0
Destroy the current instance.
FX_GetNextFile
FX_BOOL FX_GetNextFile(void *handle, CFX_ByteString &filename, FX_BOOL &bFolder, FX_LPCSTR absPath=0)
Read next entry in the folder.
IFX_FileRead::ReadBlock
virtual size_t ReadBlock(void *buffer, size_t size)
Read data block from stream.
Definition: fx_stream.h:648