Foxit PDF Conversion SDK

Public Member Functions | Protected Member Functions | List of all members
CFX_CachedFileRead Class Reference
FXCRT

Cached file read interface. More...

Inheritance diagram for CFX_CachedFileRead:

## Public Member Functions
| CFX_CachedFileRead ()
| Constructor.
virtual | ~CFX_CachedFileRead ()
| Destructor.
FX_BOOL | AttachFile (IFX_FileRead *pFile, FX_BOOL bTakeOver)
| Attach a file read. More...
virtual FX_INT64 | GetPosition ()
| Get the current reading position in stream. More...
virtual FX_INT64 | GetSize ()
| Get total size of the file. More...
FX_BOOL | Init (FX_INT32 nChunkSize, FX_INT32 nChunkCount, FX_LPVOID pBuffer, IFX_Allocator *pAllocator=0)
| Initialize the chunk size and chunk count. More...
virtual FX_BOOL | IsEOF ()
| Determine whether reach the end of stream. More...
FX_BOOL | PreCache (FX_INT64 offset, FX_INT32 nCacheCount)
| Attach a file read. More...
virtual FX_BOOL | ReadBlock (void *buffer, FX_INT64 offset, size_t size)
| Read a data block from the file. More...
virtual size_t | ReadBlock (void *buffer, size_t size)
| Read data block from stream. More...
Public Member Functions inherited from IFX_FileStream
virtual FX_BOOL | WriteBlock (const void *buffer, size_t size)
| Write a block data to the end of current stream. More...
Public Member Functions inherited from IFX_FileRead
virtual void | ClearRange ()
| Clear accessing range set by function IFX_FileRead::SetRange. More...
virtual FX_INT64 | SetPosition (FX_INT64 pos)
| Set the current file accessing position. More...
virtual FX_BOOL | SetRange (FX_INT64 offset, FX_INT64 size)
| Set accessing range. More...

## Protected Member Functions
virtual FX_BOOL | Flush ()
| Flush internal buffer. Unsupported for reading mode, return false directly.
virtual void | Release ()
| Destroy the current instance. More...
virtual IFX_FileStream * | Retain ()
| Create a shared instance. More...
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.

## Detailed Description

Cached file read interface.

## Member Function Documentation

## ◆ AttachFile()

FX_BOOL CFX_CachedFileRead::AttachFile | ( | IFX_FileRead * | pFile,
|  | FX_BOOL | bTakeOver
| ) |  |

Attach a file read.

Parameters

  [in] | pFile | The file to be attached.
  [in] | bTakeOver | Take over the file or not.

Returns
  true means success, while false means failure.

## ◆ GetPosition()

virtual FX_INT64 CFX_CachedFileRead::GetPosition | ( |  | ) |
| virtual

Get the current reading position in stream.

Returns
  The current reading position in stream.

Implements IFX_FileStream.

## ◆ GetSize()

virtual FX_INT64 CFX_CachedFileRead::GetSize | ( |  | ) |
| virtual

Get total size of the file.

Returns
  File size, in bytes. Implementation can return 0 for any error.

Implements IFX_FileStream.

## ◆ Init()

FX_BOOL CFX_CachedFileRead::Init | ( | FX_INT32 | nChunkSize,
|  | FX_INT32 | nChunkCount,
|  | FX_LPVOID | pBuffer,
|  | IFX_Allocator * | pAllocator = `0`
| ) |  |

Initialize the chunk size and chunk count.

Parameters

  [in] | nChunkSize | The size of each chunk.
  [in] | nChunkCount | The total count of chunks.
  [in] | pBuffer | External buffer. NULL means cache is disabled.
  [in] | pAllocator | Allocator used in this class. NULL means to use default allocator. Default value: NULL.

Returns
  true means success, while false means failure.

## ◆ IsEOF()

virtual FX_BOOL CFX_CachedFileRead::IsEOF | ( |  | ) |
| virtual

Determine whether reach the end of stream.

Returns
  true means reach the end of stream, and false means not yet.

Implements IFX_FileStream.

## ◆ PreCache()

FX_BOOL CFX_CachedFileRead::PreCache | ( | FX_INT64 | offset,
|  | FX_INT32 | nCacheCount
| ) |  |

Attach a file read.

Parameters

  [in] | offset | The file to be attached.
  [in] | nCacheCount | Take over the file or not.

Returns
  true means success, while false means failure.

## ◆ ReadBlock() [1/2]

virtual FX_BOOL CFX_CachedFileRead::ReadBlock | ( | void * | buffer,
|  | FX_INT64 | offset,
|  | size_t | size
| ) |  |
| virtual

Read a data block from the file.

Parameters

  [in,out] | buffer | Pointer to a buffer receiving read data
  [in] | offset | Byte offset from beginning of the file
  [in] | size | Number of bytes for the block.

Returns
  true means success, while false means failure.

Implements IFX_FileStream.

## ◆ ReadBlock() [2/2]

virtual size_t CFX_CachedFileRead::ReadBlock | ( | void * | buffer,
|  | size_t | size
| ) |  |
| virtual

Read data block from stream.

Parameters

  [in,out] | buffer | Buffer to store data.
  [in] | size | Total size of buffer, in bytes.

Returns
  The length of data stored in buffer. 0 means error or no data.

Implements IFX_FileStream.

## ◆ Release()

virtual void CFX_CachedFileRead::Release | ( |  | ) |
| protected virtual

Destroy the current instance.

Returns
  None.

Implements IFX_FileStream.

## ◆ Retain()

virtual IFX_FileStream* CFX_CachedFileRead::Retain | ( |  | ) |
| protected virtual

Create a shared instance.

Returns
  File stream interface.

Implements IFX_FileStream.