Go to the documentation of this file.
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_
95 #if _FX_OS_ != _FX_EMBEDDED_
132 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_
133 #if defined(_FX_LARGEFILE_SUPPORT_)
135 #define _FX_LARGEFILE_USED_
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))
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
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_)
154 #define _FX_LARGEFILE_USED_
156 #ifndef _LARGEFILE_SOURCE
157 #define _LARGEFILE_SOURCE
159 #ifndef _LARGEFILE64_SOURCE
160 #define _LARGEFILE64_SOURCE
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))
169 #define FX_GETBYTEOFFSET32(a) 0
170 #define FX_GETBYTEOFFSET40(a) 0
171 #define FX_GETBYTEOFFSET48(a) 0
172 #define FX_GETBYTEOFFSET56(a) 0
176 #include <sys/stat.h>
182 #define O_LARGEFILE 0
186 #if defined(_FX_LARGEFILE_SUPPORT_)
187 #if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_LINUX_EMBEDDED_ || _FX_OS_ == _FX_ANDROID_
190 #ifndef _CHROME_PNACL_
191 #define _FX_USE_OFF64_T_
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
200 #ifndef _CHROME_PNACL_
201 #define FX_FILESIZE off_t
203 #define FX_FILESIZE FX_INT32
206 #else //do not support large file.
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
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))
226 #define FX_FILEMODE_Write 0
228 #define FX_FILEMODE_ReadOnly 1
230 #define FX_FILEMODE_Truncate 2 //
300 size_t FX_File_Read(FX_HFILE hFile,
void* pBuffer,
size_t szBuffer);
321 size_t FX_File_Write(FX_HFILE hFile,
const void* pBuffer,
size_t szBuffer);
446 #if !defined(__EMSCRIPTEN__) && !defined(SWIGJAVA)
491 #if !defined(__EMSCRIPTEN__) && !defined(SWIGJAVA)
554 virtual size_t ReadBlock(
void* buffer,
size_t size) = 0;
631 virtual size_t ReadBlock(
void* buffer,
size_t size) {
return 0;}
642 #if !defined(__EMSCRIPTEN__) && !defined(SWIGJAVA)
729 virtual size_t ReadBlock(
void* buffer,
size_t size) = 0;
758 #if !defined(__EMSCRIPTEN__) && !defined(SWIGJAVA)
840 virtual size_t ReadBlock(
void* buffer,
size_t size) = 0;
882 friend class CFX_ChunkFileStreamsManager;
889 class CFX_ChunkFileStreamsManagerImpl;
890 class CFX_ChunkFileStreamsManager :
public CFX_Object
900 CFX_ChunkFileStreamsManager(
IFX_FileStream* pFileStream,
size_t nChunkSize = 1024);
907 ~CFX_ChunkFileStreamsManager();
918 std::shared_ptr<CFX_ChunkFileStreamsManagerImpl> m_pImpl;
974 class IFX_FileCollection
977 virtual void Release() = 0;
983 virtual ~IFX_FileCollection() {}
1015 virtual void EstimateSize(
size_t nInitSize,
size_t nGrowSize) = 0;
1117 virtual size_t ReadBlock(
void* buffer,
size_t size) = 0;
1155 #define FX_FILECACHE_CHUNKSIZE 32768
1156 #define FX_FILECACHE_CHUNKCOUNT 64
1235 virtual size_t ReadBlock(
void* buffer,
size_t size);
1238 FXMT_LOCKOBJECT_DEFINE(m_LockObj);
1254 #endif // _FX_STREAM_H_
FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_INT64 szFile)
Truncate file size.
virtual FX_BOOL WriteBlock(const void *pData, size_t size)
Write a block data to the end.
Definition: fx_stream.h:489
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:715
File writing interface.
Definition: fx_stream.h:453
virtual ~CFX_CachedFileRead()
Destructor.
Chunk-based File stream interface, reading & writing.
Definition: fx_stream.h:793
virtual void Release()=0
Called when to release the current instance.
virtual IFX_FileStream * Retain()
Create a shared instance.
virtual void AttachBuffer(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver=false)=0
Attach a memory buffer.
FX_BOOL AttachFile(IFX_FileRead *pFile, FX_BOOL bTakeOver)
Attach a file read.
IFX_FileAccess * FX_CreateDefaultFileAccess(FX_WSTR wsPath, IFX_Allocator *pAllocator=0)
Create a CRT based file I/O interface.
wchar_t FX_WCHAR
Compiler dependant Unicode character (16-bit for Microsoft Compiler, 32-bit for gcc).
Definition: fx_system.h:721
virtual FX_BOOL WriteBlock(const void *pData, size_t size)=0
Write a block data.
size_t FX_File_Read(FX_HFILE hFile, void *pBuffer, size_t szBuffer)
Read data from the current file accessing position.
virtual void Release()=0
Called when to release everything.
size_t FX_File_WritePos(FX_HFILE hFile, const void *pBuffer, size_t szBuffer, FX_INT64 pos)
Write data at specified position.
Stream reading interface.
Definition: fx_stream.h:524
virtual FX_BOOL ReadBlock(void *buffer, FX_INT64 offset, size_t size)=0
Read a data block from stream.
FX_BOOL FX_CreateFolder(FX_LPCSTR path)
Create new folder.
File stream interface, reading & writing.
Definition: fx_stream.h:675
virtual FX_BOOL IsEOF()=0
Determine whether reach the end of stream.
virtual IFX_FileAccess * Retain()=0
Create a shared instance.
virtual FX_BOOL IsEOF()
Determine whether reach the end of stream.
Definition: fx_stream.h:591
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_BOOL FX_File_Copy(FX_BSTR fileNameSrc, FX_BSTR fileNameDst)
Copy file.
File reading interface.
Definition: fx_stream.h:570
virtual FX_BOOL WriteBlock(const void *buffer, FX_INT64 offset, size_t size)=0
Write a block data into stream.
FX_INT64 FX_File_SetPosition(FX_HFILE hFile, FX_INT64 pos)
Set the current file accessing position.
FX_INT64 FX_File_GetPosition(FX_HFILE hFile)
Get the current file accessing position.
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.
IFX_BufferRead stream provides an optimized approach to read stream data. Usually,...
Definition: fx_stream.h:1086
virtual void Release()=0
Destroy the current instance.
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.
virtual size_t GetBlockSize()=0
Get the size of data in internal buffer.
virtual FX_INT64 SetPosition(FX_INT64 pos)
Set the current file accessing position.
Definition: fx_stream.h:563
virtual size_t ReadBlock(void *buffer, size_t size)=0
Read data block from sequential stream.
virtual FX_INT64 GetSize()=0
Get the current stream size, in bytes.
Stream writing interface.
Definition: fx_stream.h:424
void * FX_LPVOID
Pointer to any type.
Definition: fx_system.h:645
virtual void GetPath(CFX_WideString &wsPath)=0
Get current path string.
#define FX_DEFINEHANDLE(name)
Macro to define a handle type.
Definition: fx_system.h:760
virtual void DetachBuffer()=0
Detach the current memory buffer.
virtual FX_BOOL IsEOF()=0
Determine whether reach the end of stream.
void * FX_OpenFolder(FX_LPCSTR path)
Open a folder for reading.
virtual FX_BOOL ReadBlock(void *buffer, FX_INT64 offset, size_t size)
Read a data block from the file.
virtual void Release()
Destroy the current instance.
void * FX_POSITION
A value used to denote the position of an element in a collection.
Definition: fx_system.h:649
virtual FX_INT64 GetPosition()
Get the current reading position in stream.
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:674
virtual FX_BOOL IsConsecutive() const =0
Determine whether the current mode is consecutive or not.
virtual FX_INT64 GetSize()=0
Get the current stream size, in bytes.
FX_BOOL FX_File_Exist(FX_BSTR fileName)
Determine whether a file exists or not.
virtual FX_BOOL ReadBlock(void *buffer, FX_INT64 offset, size_t size)=0
Read a data block from the file.
virtual void EstimateSize(size_t nInitSize, size_t nGrowSize)=0
Change initialize size and grow size.
BYTE STRING CLASS.
Definition: fx_string.h:317
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:1247
Foxit allocator interface.
Definition: fx_memory.h:997
virtual FX_BOOL Flush()
Flush stream data.
Definition: fx_stream.h:444
Header file for Memory management related definitions and classes.
virtual void Release()=0
Destroy the current instance.
virtual FX_INT64 GetBlockOffset()=0
Get the offset of data in internal buffer.
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:725
Cached file read interface.
Definition: fx_stream.h:1159
virtual FX_INT64 GetSize()=0
Get total size of the file.
virtual FX_BOOL Flush()=0
Flush internal buffer of the file.
#define FXSYS_assert
Assertion.
Definition: fx_system.h:792
FX_BOOL FX_File_Move(FX_BSTR fileNameSrc, FX_BSTR fileNameDst)
Move file.
virtual FX_BOOL Flush()
Flush internal buffer. Unsupported for reading mode, return false directly.
Definition: fx_stream.h:1249
virtual FX_BOOL WriteBlock(const void *buffer, size_t size)
Write a block data to the end of current stream.
Definition: fx_stream.h:749
virtual FX_LPBYTE GetBuffer() const =0
Get the current memory buffer.
virtual FX_BOOL IsEOF()=0
Determine whether reach the end of stream.
char const * FX_LPCSTR
Pointer to constant 8-bit Windows (ANSI) characters.
Definition: fx_system.h:696
virtual FX_INT64 SetPosition(FX_INT64 pos)
Set the current file accessing position.
Definition: fx_stream.h:640
#define FX_FILESIZE
Support large file directly.
Definition: fx_stream.h:138
unsigned char const * FX_LPCBYTE
Pointer to a constant FX_BYTE.
Definition: fx_system.h:660
virtual IFX_FileStream * Retain()=0
Create a shared instance.
virtual size_t ReadBlock(void *buffer, size_t size)=0
Read data block from sequential stream.
virtual FX_LPCBYTE GetBlockBuffer()=0
Get internal buffer of block data.
virtual IFX_FileStream * CreateFileStream(FX_DWORD dwModes)=0
Create IFX_FileStream to operate file.
Memory stream interface.
Definition: fx_stream.h:991
virtual void ClearRange()
Clear accessing range set by function IFX_FileRead::SetRange.
Definition: fx_stream.h:612
FX_BOOL PreCache(FX_INT64 offset, FX_INT32 nCacheCount)
Attach a file read.
virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart=false)=0
Read the next block in sequential stream.
const typedef CFX_ByteStringC & FX_BSTR
A reference to a constant CFX_ByteStringC object.
Definition: fx_string.h:285
FX_INT64 FX_File_GetSize(FX_HFILE hFile)
Get file size.
FX_HFILE FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode, IFX_Allocator *pAllocator=0)
Open file with specified accessing mode.
FX_BOOL FX_IsFilePathExist(FX_LPCWSTR path)
Check if the path exists, including file path and folder path.
File access interface, open file.
Definition: fx_stream.h:925
FX_BOOL Init(FX_INT32 nChunkSize, FX_INT32 nChunkCount, FX_LPVOID pBuffer, IFX_Allocator *pAllocator=0)
Initialize the chunk size and chunk count.
virtual FX_INT64 GetPosition()=0
Get the current reading position in stream.
virtual FX_BOOL ReadBlock(void *buffer, FX_INT64 offset, size_t size)=0
Read a data block from stream.
#define NULL
The null-pointer value.
Definition: fx_system.h:780
size_t FX_File_ReadPos(FX_HFILE hFile, void *pBuffer, size_t szBuffer, FX_INT64 pos)
Read data from specified position.
virtual FX_BOOL IsEOF()=0
Determine whether reach the end of stream.
virtual FX_BOOL WriteBlock(const void *pData, FX_INT64 offset, size_t size)=0
Write a block data.
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:682
const typedef CFX_WideStringC & FX_WSTR
Type definition for a reference to a constant CFX_WideStringC object.
Definition: fx_string.h:1417
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.
void FX_File_Close(FX_HFILE hFile, IFX_Allocator *pAllocator=0)
Close file.
virtual FX_INT64 GetPosition()=0
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:860
virtual FX_BOOL Flush()=0
Flush internal buffer.
virtual FX_INT64 GetSize()=0
Get total size of the file.
void FX_CloseFolder(void *handle)
Close folder handle.
virtual FX_BOOL SetRange(FX_INT64 offset, FX_INT64 size)
Set accessing range.
Definition: fx_stream.h:606
unsigned char * FX_LPBYTE
Pointer to a FX_BYTE.
Definition: fx_system.h:658
FX_WCHAR FX_GetFolderSeparator()
Get folder separator for the system. Most likely it's either /' or '\'.
FX_BOOL FX_File_Delete(FX_BSTR fileName)
Delete file.
virtual FX_BOOL Flush()=0
Flush internal buffer.
virtual FX_INT64 GetPosition()
Get the current reading position in stream.
Definition: fx_stream.h:597
CFX_CachedFileRead()
Constructor.
virtual void Release()=0
Called when to release everything.
virtual FX_BOOL IsEOF()
Determine whether reach the end of stream.
WIDE STRING CLASS.
Definition: fx_string.h:1452
virtual FX_INT64 GetPosition()=0
Get the current reading position in stream.
virtual void Release()=0
Called when to release everything.
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 FX_INT64 GetSize()
Get total size of the file.
virtual FX_BOOL WriteBlock(const void *buffer, FX_INT64 offset, size_t size)=0
Write a block data into stream.
virtual IFX_FileStream * Retain()=0
Create a shared instance.
FX_BOOL FX_File_Flush(FX_HFILE hFile)
Flush internal buffer if need.
virtual void Release()=0
Called when to release everything.
virtual void Release()=0
Destroy the current instance.
FX_BOOL FX_GetNextFile(void *handle, CFX_ByteString &filename, FX_BOOL &bFolder, FX_LPCSTR absPath=0)
Read next entry in the folder.
virtual size_t ReadBlock(void *buffer, size_t size)
Read data block from stream.
Definition: fx_stream.h:631
@2024 Foxit Software Incorporated. All rights reserved.