Foxit PDF Conversion 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 
92 
93 #endif
94 
95 #if _FX_OS_ != _FX_EMBEDDED_
96 //<<<+++OPENSOURCE_BEGIN LIC==FOXIT
113 
122 //<<<+++OPENSOURCE_END
123 #endif
124 
125 //*****************************************************************************
126 //* File access
127 //*****************************************************************************
130 
131  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
132  #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_
133  #if defined(_FX_LARGEFILE_SUPPORT_)
134 
135  #define _FX_LARGEFILE_USED_
136 
138  #define FX_FILESIZE FX_INT64
139  #define FX_GETBYTEOFFSET32(a) ((FX_BYTE)((a>>16)>>16))
140  #define FX_GETBYTEOFFSET40(a) ((FX_BYTE)(((a>>16)>>16)>>8))
141  #define FX_GETBYTEOFFSET48(a) ((FX_BYTE)(((a>>16)>>16)>>16))
142  #define FX_GETBYTEOFFSET56(a) ((FX_BYTE)((((a>>16)>>16)>>16)>>8))
143  #else
144 
145  #define FX_FILESIZE FX_INT32
146  #define FX_GETBYTEOFFSET32(a) 0
147  #define FX_GETBYTEOFFSET40(a) 0
148  #define FX_GETBYTEOFFSET48(a) 0
149  #define FX_GETBYTEOFFSET56(a) 0
150  #endif
151  #elif _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_ANDROID_ || _FX_OS_==_FX_LINUX_EMBEDDED_
152  #if defined(_FX_LARGEFILE_SUPPORT_)
153 
154  #define _FX_LARGEFILE_USED_
155 
156  #ifndef _LARGEFILE_SOURCE
157  #define _LARGEFILE_SOURCE
158  #endif
159  #ifndef _LARGEFILE64_SOURCE
160  #define _LARGEFILE64_SOURCE
161  #endif
162  #endif
163  #if defined(_FX_LARGEFILE_SUPPORT_)
164  #define FX_GETBYTEOFFSET32(a) ((FX_BYTE)((a>>16)>>16))
165  #define FX_GETBYTEOFFSET40(a) ((FX_BYTE)(((a>>16)>>16)>>8))
166  #define FX_GETBYTEOFFSET48(a) ((FX_BYTE)(((a>>16)>>16)>>16))
167  #define FX_GETBYTEOFFSET56(a) ((FX_BYTE)((((a>>16)>>16)>>16)>>8))
168  #else
169  #define FX_GETBYTEOFFSET32(a) 0
170  #define FX_GETBYTEOFFSET40(a) 0
171  #define FX_GETBYTEOFFSET48(a) 0
172  #define FX_GETBYTEOFFSET56(a) 0
173  #endif
174  #include <fcntl.h>
175  #include <unistd.h>
176  #include <sys/stat.h>
177 
178  #ifndef O_BINARY
179  #define O_BINARY 0
180  #endif
181  #ifndef O_LARGEFILE
182  #define O_LARGEFILE 0
183  #endif
184 
186  #if defined(_FX_LARGEFILE_SUPPORT_)
187  #if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_LINUX_EMBEDDED_ || _FX_OS_ == _FX_ANDROID_
188  // mac and bsd are always 64 bit. use off_t
189  // linux and android uses off64_t
190 #ifndef _CHROME_PNACL_
191  #define _FX_USE_OFF64_T_
192 #endif
193  #endif
194  #endif
195  #if defined(_FX_USE_OFF64_T_)
196  #define FX_FILESIZE off64_t
197  #elif _FX_OS_ == _FX_LINUX_EMBEDDED_
198  #define FX_FILESIZE FX_INT32
199  #else
200  #ifndef _CHROME_PNACL_
201  #define FX_FILESIZE off_t
202  #else
203  #define FX_FILESIZE FX_INT32
204  #endif
205  #endif
206  #else //do not support large file.
207 
208  #define FX_FILESIZE FX_INT32
209  #define FX_GETBYTEOFFSET32(a) 0
210  #define FX_GETBYTEOFFSET40(a) 0
211  #define FX_GETBYTEOFFSET48(a) 0
212  #define FX_GETBYTEOFFSET56(a) 0
213  #endif
214  //<<<+++OPENSOURCE_MUST_END
215 
216 #define FX_GETBYTEOFFSET24(a) ((FX_BYTE)(a>>24))
217 #define FX_GETBYTEOFFSET16(a) ((FX_BYTE)(a>>16))
218 #define FX_GETBYTEOFFSET8(a) ((FX_BYTE)(a>>8))
219 #define FX_GETBYTEOFFSET0(a) ((FX_BYTE)(a))
220 
226 #define FX_FILEMODE_Write 0
227 
228 #define FX_FILEMODE_ReadOnly 1
229 
230 #define FX_FILEMODE_Truncate 2 //
231 
243 FX_HFILE FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocator = NULL);
254 FX_HFILE FX_File_Open(FX_WSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocator = NULL);
263 void FX_File_Close(FX_HFILE hFile, IFX_Allocator* pAllocator = NULL);
264 //<<<+++OPENSOURCE_END
265 
273 FX_FILESIZE FX_File_GetSize(FX_HFILE hFile);
281 FX_FILESIZE FX_File_GetPosition(FX_HFILE hFile);
290 FX_FILESIZE FX_File_SetPosition(FX_HFILE hFile, FX_FILESIZE pos);
300 size_t FX_File_Read(FX_HFILE hFile, void* pBuffer, size_t szBuffer);
311 size_t FX_File_ReadPos(FX_HFILE hFile, void* pBuffer, size_t szBuffer, FX_FILESIZE pos);
321 size_t FX_File_Write(FX_HFILE hFile, const void* pBuffer, size_t szBuffer);
332 size_t FX_File_WritePos(FX_HFILE hFile, const void* pBuffer, size_t szBuffer, FX_FILESIZE pos);
340 FX_BOOL FX_File_Flush(FX_HFILE hFile);
349 FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile);
350 
358 FX_BOOL FX_File_Exist(FX_BSTR fileName);
366 FX_BOOL FX_File_Exist(FX_WSTR fileName);
374 FX_BOOL FX_File_Delete(FX_BSTR fileName);
382 FX_BOOL FX_File_Delete(FX_WSTR fileName);
391 FX_BOOL FX_File_Copy(FX_BSTR fileNameSrc, FX_BSTR fileNameDst);
400 FX_BOOL FX_File_Copy(FX_WSTR fileNameSrc, FX_WSTR fileNameDst);
409 FX_BOOL FX_File_Move(FX_BSTR fileNameSrc, FX_BSTR fileNameDst);
418 FX_BOOL FX_File_Move(FX_WSTR fileNameSrc, FX_WSTR fileNameDst);
419 
420 //*****************************************************************************
421 //* IFX_StreamWrite/IFX_FileWrite
422 //*****************************************************************************
425 {
426  public:
428  virtual void Release() = 0;
429 
438  virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0;
444  virtual FX_BOOL Flush() { return true; }
445 
446  protected:
447  virtual ~IFX_StreamWrite() {}
448 };
449 
452 {
453  public:
455  virtual void Release() = 0;
456 
462  virtual FX_FILESIZE GetSize() = 0;
468  virtual FX_BOOL Flush() = 0;
478  virtual FX_BOOL WriteBlock(const void* pData, FX_FILESIZE offset, size_t size) = 0;
487  virtual FX_BOOL WriteBlock(const void* pData, size_t size) {return WriteBlock(pData, GetSize(), size);}
488 
489  protected:
490  virtual ~IFX_FileWrite() {}
491 };
492 
503 
514 //<<<+++OPENSOURCE_END
515 
516 //*****************************************************************************
517 //* IFX_FileRead
518 //*****************************************************************************
521 {
522  public:
528  virtual void Release() = 0;
529 
535  virtual FX_BOOL IsEOF() = 0;
541  virtual FX_FILESIZE GetPosition() = 0;
550  virtual size_t ReadBlock(void* buffer, size_t size) = 0;
551 
559  virtual FX_FILESIZE SetPosition(FX_FILESIZE pos) { FXSYS_assert(false && "Unsupport"); return -1; }
560 
561  protected:
562  virtual ~IFX_StreamRead() {}
563 };
564 
567 {
568  public:
574  virtual void Release() = 0;
575 
581  virtual FX_FILESIZE GetSize() = 0;
587  virtual FX_BOOL IsEOF() {return false;}
593  virtual FX_FILESIZE GetPosition() {return 0;}
602  virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size) {return false;}
608  virtual void ClearRange() {}
618  virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
627  virtual size_t ReadBlock(void* buffer, size_t size) {return 0;}
628 
636  virtual FX_FILESIZE SetPosition(FX_FILESIZE pos) { FXSYS_assert(false && "Unsupport"); return -1; }
637 
638  protected:
639  virtual ~IFX_FileRead() {}
640 };
641 
651 IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL);
652 
663 //<<<+++OPENSOURCE_END
664 
665 //*****************************************************************************
666 //* IFX_FileStream
667 //*****************************************************************************
670 : public IFX_FileRead, public IFX_FileWrite
671 {
672  public:
678  virtual IFX_FileStream* Retain() = 0;
684  virtual void Release() = 0;
685 
691  virtual FX_FILESIZE GetSize() = 0;
697  virtual FX_BOOL IsEOF() = 0;
703  virtual FX_FILESIZE GetPosition() = 0;
704 
714  virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
723  virtual size_t ReadBlock(void* buffer, size_t size) = 0;
724 
734  virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) = 0;
743  virtual FX_BOOL WriteBlock(const void* buffer, size_t size) {return WriteBlock(buffer, GetSize(), size);}
744 
750  virtual FX_BOOL Flush() = 0;
751 
752  protected:
753  virtual ~IFX_FileStream() {}
754 };
755 
766 IFX_FileStream* FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes, IFX_Allocator* pAllocator = NULL);
767 
778 IFX_FileStream* FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwModes, IFX_Allocator* pAllocator = NULL);
779 //<<<+++OPENSOURCE_END
780 
781 //*****************************************************************************
782 //* IFX_ChunkFileStream
783 //*****************************************************************************
786 {
787  public:
793  virtual void Release() = 0;
794 
800  virtual FX_FILESIZE GetSize() = 0;
806  virtual FX_BOOL IsEOF() = 0;
812  virtual FX_FILESIZE GetPosition() = 0;
813 
823  virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
832  virtual size_t ReadBlock(void* buffer, size_t size) = 0;
833 
843  virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) = 0;
852  virtual FX_BOOL WriteBlock(const void* buffer, size_t size)
853  {
854  return WriteBlock(buffer, GetSize(), size);
855  }
856 
862  virtual FX_BOOL Flush() = 0;
863 
864  protected:
870  virtual IFX_FileStream* Retain() = 0;
871 
872  virtual ~IFX_ChunkFileStream() {}
873 
874  friend class CFX_ChunkFileStreamsManager;
875 };
876 
877 //*****************************************************************************
878 //* CFX_ChunkFileStreamsManager
879 //*****************************************************************************
881 class CFX_ChunkFileStreamsManagerImpl;
882 class CFX_ChunkFileStreamsManager : public CFX_Object
883 {
884  public:
892  CFX_ChunkFileStreamsManager(IFX_FileStream* pFileStream, size_t nChunkSize = 1024);
899  ~CFX_ChunkFileStreamsManager();
900 
907  IFX_ChunkFileStream* CreateChunkFileStream();
908 
909  private:
910  std::shared_ptr<CFX_ChunkFileStreamsManagerImpl> m_pImpl;
911 };
912 
913 //*****************************************************************************
914 //* IFX_FileAccess
915 //*****************************************************************************
918 {
919  public:
925  virtual void Release() = 0;
926 
932  virtual IFX_FileAccess* Retain() = 0;
940  virtual void GetPath(CFX_WideString& wsPath) = 0;
941 
949  virtual IFX_FileStream* CreateFileStream(FX_DWORD dwModes) = 0;
950 
951  protected:
952  virtual ~IFX_FileAccess() {}
953 };
954 
965 
966 class IFX_FileCollection
967 {
968  public:
969  virtual void Release() = 0;
970 
971  virtual FX_POSITION GetStartPos() = 0;
972  virtual IFX_FileAccess* GetNextFile(FX_POSITION& pos) = 0;
973 
974  protected:
975  virtual ~IFX_FileCollection() {}
976 };
977 //<<<+++OPENSOURCE_END
978 
979 //*****************************************************************************
980 //* Memory stream
981 //*****************************************************************************
984 {
985  public:
986  virtual ~IFX_MemoryStream() {}
987 
993  virtual FX_BOOL IsConsecutive() const = 0;
1007  virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0;
1016  virtual FX_LPBYTE GetBuffer() const = 0;
1031  virtual void AttachBuffer(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = false) = 0;
1039  virtual void DetachBuffer() = 0;
1040 };
1054 IFX_MemoryStream* FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = false, IFX_Allocator* pAllocator = NULL);
1055 
1067 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = false, IFX_Allocator* pAllocator = NULL);
1068 //<<<+++OPENSOURCE_END
1069 
1070 //*****************************************************************************
1071 //* Buffer read stream
1072 //*****************************************************************************
1079 {
1080  public:
1086  virtual void Release() = 0;
1087 
1093  virtual FX_BOOL IsEOF() = 0;
1099  virtual FX_FILESIZE GetPosition() = 0;
1100 
1109  virtual size_t ReadBlock(void* buffer, size_t size) = 0;
1110 
1118  virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = false) = 0;
1124  virtual FX_LPCBYTE GetBlockBuffer() = 0;
1130  virtual size_t GetBlockSize() = 0;
1138  virtual FX_FILESIZE GetBlockOffset() = 0;
1139 
1140  protected:
1141  virtual ~IFX_BufferRead() {}
1142 };
1143 
1144 //*****************************************************************************
1145 //* Cached file read
1146 //*****************************************************************************
1147 #define FX_FILECACHE_CHUNKSIZE 32768
1148 #define FX_FILECACHE_CHUNKCOUNT 64
1149 
1151 class CFX_CachedFileRead : public IFX_FileStream, public CFX_Object
1152 {
1153  public:
1157  virtual ~CFX_CachedFileRead();
1158 
1170  FX_BOOL Init(FX_INT32 nChunkSize, FX_INT32 nChunkCount, FX_LPVOID pBuffer, IFX_Allocator* pAllocator = NULL);
1179  FX_BOOL AttachFile(IFX_FileRead* pFile, FX_BOOL bTakeOver);
1188  FX_BOOL PreCache(FX_FILESIZE offset, FX_INT32 nCacheCount);
1189 
1195  virtual FX_FILESIZE GetSize();
1201  virtual FX_BOOL IsEOF();
1207  virtual FX_FILESIZE GetPosition();
1208 
1218  virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size);
1227  virtual size_t ReadBlock(void* buffer, size_t size);
1228 
1229  protected:
1230  FXMT_LOCKOBJECT_DEFINE(m_LockObj);
1231  FX_LPVOID m_pData;
1232  FX_DWORD m_dwCount;
1233 
1234  /* @brief Create a shared instance. */
1235  virtual IFX_FileStream* Retain();
1236  /* @brief Called when to release everything */
1237  virtual void Release();
1239  virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) {return false;}
1241  virtual FX_BOOL Flush() {return false;}
1242 };
1243 //<<<+++OPENSOURCE_END
1244 
1245 //<<<+++OPENSOURCE_MUST_BEGIN
1246 #endif // _FX_STREAM_H_
1247 //<<<+++OPENSOURCE_MUST_END
1248 
1251 //<<<+++OPENSOURCE_END
virtual void GetPath(CFX_WideString &wsPath)=0
Get current path string.
virtual FX_BOOL ReadBlock(void *buffer, FX_INT64 offset, size_t size)=0
Read a data block from the file.
virtual FX_INT64 GetSize()
Get total size of the file.
void * FX_LPVOID
Pointer to any type.
Definition: fx_system.h:645
Memory stream interface.
Definition: fx_stream.h:983
virtual size_t ReadBlock(void *buffer, size_t size)
Read data block from stream.
Definition: fx_stream.h:627
wchar_t FX_WCHAR
Compiler dependant Unicode character (16-bit for Microsoft Compiler, 32-bit for gcc).
Definition: fx_system.h:721
virtual void Release()=0
Called when to release everything.
IFX_FileAccess * FX_CreateDefaultFileAccess(FX_WSTR wsPath, IFX_Allocator *pAllocator=0)
Create a CRT based file I/O interface.
File writing interface.
Definition: fx_stream.h:451
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:715
FX_BOOL AttachFile(IFX_FileRead *pFile, FX_BOOL bTakeOver)
Attach a file read.
virtual void Release()=0
Destroy the current instance.
CONSTANT WIDE STRING CLASS.
Definition: fx_string.h:1205
virtual FX_BOOL WriteBlock(const void *pData, FX_INT64 offset, size_t size)=0
Write a block data.
virtual FX_BOOL SetRange(FX_INT64 offset, FX_INT64 size)
Set accessing range.
Definition: fx_stream.h:602
FX_BOOL FX_File_Exist(FX_BSTR fileName)
Determine whether a file exists or not.
void FX_File_Close(FX_HFILE hFile, IFX_Allocator *pAllocator=0)
Close file.
virtual FX_INT64 SetPosition(FX_INT64 pos)
Set the current file accessing position.
Definition: fx_stream.h:559
FX_BOOL FX_File_Copy(FX_BSTR fileNameSrc, FX_BSTR fileNameDst)
Copy file.
virtual void Release()=0
Destroy the current instance.
virtual FX_BOOL IsEOF()=0
Determine whether reach the end of stream.
Chunk-based File stream interface, reading & writing.
Definition: fx_stream.h:785
virtual FX_LPBYTE GetBuffer() const =0
Get the current memory buffer.
virtual FX_BOOL WriteBlock(const void *buffer, FX_INT64 offset, size_t size)=0
Write a block data into stream.
void FX_CloseFolder(void *handle)
Close folder handle.
virtual FX_LPCBYTE GetBlockBuffer()=0
Get internal buffer of block data.
FX_WCHAR FX_GetFolderSeparator()
Get folder separator for the system. Most likely it's either /' or '\'.
virtual size_t ReadBlock(void *buffer, size_t size)=0
Read data block from sequential stream.
virtual FX_BOOL IsEOF()=0
Determine whether reach the end of stream.
virtual FX_INT64 GetPosition()
Get the current reading position in stream.
Definition: fx_stream.h:593
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:725
virtual void Release()=0
Called when to release everything.
virtual FX_INT64 SetPosition(FX_INT64 pos)
Set the current file accessing position.
Definition: fx_stream.h:636
virtual FX_BOOL ReadBlock(void *buffer, FX_INT64 offset, size_t size)=0
Read a data block from stream.
size_t FX_File_WritePos(FX_HFILE hFile, const void *pBuffer, size_t szBuffer, FX_INT64 pos)
Write data at specified position.
FX_BOOL FX_GetNextFile(void *handle, CFX_ByteString &filename, FX_BOOL &bFolder, FX_LPCSTR absPath=0)
Read next entry in the folder.
FX_HFILE FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode, IFX_Allocator *pAllocator=0)
Open file with specified accessing mode.
FX_BOOL Init(FX_INT32 nChunkSize, FX_INT32 nChunkCount, FX_LPVOID pBuffer, IFX_Allocator *pAllocator=0)
Initialize the chunk size and chunk count.
Cached file read interface.
Definition: fx_stream.h:1151
virtual void Release()=0
Called when to release everything.
File reading interface.
Definition: fx_stream.h:566
WIDE STRING CLASS.
Definition: fx_string.h:1452
Stream writing interface.
Definition: fx_stream.h:424
void * FX_POSITION
A value used to denote the position of an element in a collection.
Definition: fx_system.h:649
size_t FX_File_Read(FX_HFILE hFile, void *pBuffer, size_t szBuffer)
Read data from the current file accessing position.
virtual FX_INT64 GetPosition()=0
Get the current reading position in stream.
virtual FX_INT64 GetPosition()
Get the current reading position in stream.
virtual FX_BOOL WriteBlock(const void *buffer, size_t size)
Write a block data to the end of current stream.
Definition: fx_stream.h:743
Stream reading interface.
Definition: fx_stream.h:520
virtual FX_BOOL IsEOF()
Determine whether reach the end of stream.
Definition: fx_stream.h:587
virtual FX_INT64 GetPosition()=0
Get the current reading position in stream.
size_t FX_File_Write(FX_HFILE hFile, const void *pBuffer, size_t szBuffer)
Write data from the current file accessing position.
virtual FX_BOOL Flush()=0
Flush internal buffer of the file.
IFX_BufferRead stream provides an optimized approach to read stream data. Usually,...
Definition: fx_stream.h:1078
virtual FX_BOOL Flush()=0
Flush internal buffer.
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:674
virtual FX_BOOL IsEOF()=0
Determine whether reach the end of stream.
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...
size_t FX_File_ReadPos(FX_HFILE hFile, void *pBuffer, size_t szBuffer, FX_INT64 pos)
Read data from specified position.
virtual IFX_FileStream * Retain()=0
Create a shared instance.
virtual FX_INT64 GetBlockOffset()=0
Get the offset of data in internal buffer.
virtual size_t GetBlockSize()=0
Get the size of data in internal buffer.
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:682
File access interface, open file.
Definition: fx_stream.h:917
FX_BOOL FX_CreateFolder(FX_LPCSTR path)
Create new folder.
void * FX_OpenFolder(FX_LPCSTR path)
Open a folder for reading.
virtual void Release()
Destroy the current instance.
virtual FX_BOOL Flush()
Flush stream data.
Definition: fx_stream.h:444
char const * FX_LPCSTR
Pointer to constant 8-bit Windows (ANSI) characters.
Definition: fx_system.h:696
virtual FX_BOOL Flush()
Flush internal buffer. Unsupported for reading mode, return false directly.
Definition: fx_stream.h:1241
FX_BOOL FX_IsFilePathExist(FX_LPCWSTR path)
Check if the path exists, including file path and folder path.
virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart=false)=0
Read the next block in sequential stream.
File stream interface, reading & writing.
Definition: fx_stream.h:669
CFX_CachedFileRead()
Constructor.
virtual IFX_FileAccess * Retain()=0
Create a shared instance.
virtual FX_BOOL IsEOF()
Determine whether reach the end of stream.
virtual FX_BOOL WriteBlock(const void *pData, size_t size)
Write a block data to the end.
Definition: fx_stream.h:487
virtual IFX_FileStream * Retain()
Create a shared instance.
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:1239
FX_BOOL FX_File_Move(FX_BSTR fileNameSrc, FX_BSTR fileNameDst)
Move file.
unsigned char * FX_LPBYTE
Pointer to a FX_BYTE.
Definition: fx_system.h:658
virtual FX_INT64 GetSize()=0
Get total size of the file.
FX_BOOL FX_File_Delete(FX_BSTR fileName)
Delete file.
FX_INT64 FX_File_GetPosition(FX_HFILE hFile)
Get the current file accessing position.
Foxit allocator interface.
Definition: fx_memory.h:997
virtual FX_BOOL WriteBlock(const void *buffer, FX_INT64 offset, size_t size)=0
Write a block data into stream.
FX_BOOL FX_File_Flush(FX_HFILE hFile)
Flush internal buffer if need.
virtual void ClearRange()
Clear accessing range set by function IFX_FileRead::SetRange.
Definition: fx_stream.h:608
#define FXSYS_assert
Assertion.
Definition: fx_system.h:792
virtual FX_INT64 GetPosition()=0
Get the current reading position in stream.
FX_INT64 FX_File_GetSize(FX_HFILE hFile)
Get file size.
virtual size_t ReadBlock(void *buffer, size_t size)=0
Read data block from sequential stream.
virtual FX_INT64 GetSize()=0
Get total size of the file.
virtual FX_BOOL Flush()=0
Flush internal buffer.
virtual FX_BOOL IsEOF()=0
Determine whether reach the end of stream.
virtual void DetachBuffer()=0
Detach the current memory buffer.
virtual FX_INT64 GetSize()=0
Get the current stream size, in bytes.
virtual FX_BOOL ReadBlock(void *buffer, FX_INT64 offset, size_t size)=0
Read a data block from stream.
CONSTANT BYTE STRING CLASS.
Definition: fx_string.h:51
virtual void Release()=0
Called when to release everything.
virtual FX_INT64 GetPosition()=0
Get the current reading position in stream.
FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_INT64 szFile)
Truncate file size.
virtual FX_BOOL WriteBlock(const void *pData, size_t size)=0
Write a block data.
FX_BOOL PreCache(FX_INT64 offset, FX_INT32 nCacheCount)
Attach a file read.
BYTE STRING CLASS.
Definition: fx_string.h:317
virtual FX_INT64 GetSize()=0
Get the current stream size, in bytes.
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.
unsigned char const * FX_LPCBYTE
Pointer to a constant FX_BYTE.
Definition: fx_system.h:660
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.
Header file for Memory management related definitions and classes.
virtual FX_BOOL WriteBlock(const void *buffer, size_t size)
Write a block data to the end of current stream.
Definition: fx_stream.h:852
virtual void AttachBuffer(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver=false)=0
Attach a memory buffer.
virtual IFX_FileStream * Retain()=0
Create a shared instance.
#define NULL
The null-pointer value.
Definition: fx_system.h:780
#define FX_DEFINEHANDLE(name)
Macro to define a handle type.
Definition: fx_system.h:760
#define FX_FILESIZE
Support large file directly.
Definition: fx_stream.h:138
virtual FX_BOOL ReadBlock(void *buffer, FX_INT64 offset, size_t size)
Read a data block from the file.
virtual IFX_FileStream * CreateFileStream(FX_DWORD dwModes)=0
Create IFX_FileStream to operate file.
virtual FX_BOOL IsConsecutive() const =0
Determine whether the current mode is consecutive or not.
virtual void EstimateSize(size_t nInitSize, size_t nGrowSize)=0
Change initialize size and grow size.
virtual void Release()=0
Destroy the current instance.
virtual void Release()=0
Called when to release the current instance.
FX_INT64 FX_File_SetPosition(FX_HFILE hFile, FX_INT64 pos)
Set the current file accessing position.
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...
virtual ~CFX_CachedFileRead()
Destructor.