"L. Spiro Engine"
Public Member Functions | Protected Member Functions | Protected Attributes

lsf::CFileMap Class Reference

A wrapper class for file-mapping routines. More...

#include <LSFFileMap.h>

List of all members.

Public Member Functions

LSBOOL LSE_CALL CreateFileMap (const LSCHAR *_pcFile, LSF_OPEN_FILE _ofOpenType=LSF_OF_READ, LSUINT32 _ui32BufferSize=0UL)
LSBOOL LSE_CALL CreateFileMap (const LSWCHAR_T *_pwcFile, LSF_OPEN_FILE _ofOpenType=LSF_OF_READ, LSUINT32 _ui32BufferSize=0UL)
LSVOID LSE_CALL Reset ()
LSUINT32 LSE_CALL ReadBytes (LSVOID *_pvBuffer, LSUINT64 _ui64Offset, LSUINT32 _ui32Total) const
LSUINT32 LSE_CALL WriteBytes (const LSUINT8 *_pui8Buffer, LSUINT64 _ui64Offset, LSUINT32 _ui32Total)
LSUINT64 LSE_CALL GetFileSize () const

Protected Member Functions

LSUINT64 LSE_CALL GetBaseOffset (LSUINT64 _ui64Offset) const
LSUINT8 *LSE_CALL GetBuffer (LSUINT64 _ui64Offset, LSUINT32 &_ui32MaxLen) const

Protected Attributes

LSF_FILE_MAP m_fmMap
LSBOOL m_bMapped
LSVOID * m_pvAddr
LSUINTPTR m_uiptrSize
LSUINTPTR m_uiptrCurSize
LSUINT64 m_ui64FileSize
LSUINT64 m_ui64Offset

Detailed Description

A wrapper class for file-mapping routines.

Class CFileMap Description: A wrapper class for file-mapping routines. This class makes it easy to map files and use the maps in an efficient and safe way.


Member Function Documentation

LSBOOL LSE_CALL lsf::CFileMap::CreateFileMap ( const LSCHAR *  _pcFile,
LSF_OPEN_FILE  _ofOpenType = LSF_OF_READ,
LSUINT32  _ui32BufferSize = 0UL 
)

Create a file map.

Parameters:
_pcFileThe file to map. The entire file is mapped.
_ofOpenTypeFlag determining how to open the file. Valid values are LSF_OF_READ, LSF_OF_WRITE, or both.
_ui32BufferSizeBuffer size. Reading operations buffer this much of the file at a time. This allows high RAM conservation.
Returns:
Returns true if mapping was successful.
LSBOOL LSE_CALL lsf::CFileMap::CreateFileMap ( const LSWCHAR_T *  _pwcFile,
LSF_OPEN_FILE  _ofOpenType = LSF_OF_READ,
LSUINT32  _ui32BufferSize = 0UL 
)

Create a file map.

Parameters:
_pwcFileThe file to map. The entire file is mapped.
_ofOpenTypeFlag determining how to open the file. Valid values are LSF_OF_READ, LSF_OF_WRITE, or both.
_ui32BufferSizeBuffer size. Reading operations buffer this much of the file at a time. This allows high RAM conservation.
Returns:
Returns true if mapping was successful.
LSE_INLINE LSUINT64 LSE_CALL lsf::CFileMap::GetBaseOffset ( LSUINT64  _ui64Offset) const [protected]

Get the base of the pointer (offset) for the current chunk buffered. Does not actually set the offset value, but instead derives it to be used as a reference by the other functions.

Parameters:
_ui64OffsetThe desired offset into the file to be used as a base for the calculation of the chunk base.
Returns:
Returns the base offset of the chunk that matches the alignment settings and covers the given offset.
LSUINT8* LSE_CALL lsf::CFileMap::GetBuffer ( LSUINT64  _ui64Offset,
LSUINT32 &  _ui32MaxLen 
) const [protected]

Get a pointer to the requested data from the mapped file. Returns a pointer inside the current buffer and a value indicating the valid length of the data within the buffer.

Parameters:
_ui64OffsetFile offset to be translated to a virtual address containing the file data.
_ui32MaxLenUpon return, this is filled with the number of bytes that are valid from the returned pointer to the end of the current buffer.
Returns:
Returns a pointer within the current buffer that represents the requested offset within the file, along with the amount of bytes that are valid from that pointer to the end of the buffer.
LSE_INLINE LSUINT64 LSE_CALL lsf::CFileMap::GetFileSize ( ) const

Get the size of the mapped file.

Returns:
Returns the size of the mapped file, in bytes.
LSUINT32 LSE_CALL lsf::CFileMap::ReadBytes ( LSVOID *  _pvBuffer,
LSUINT64  _ui64Offset,
LSUINT32  _ui32Total 
) const

Read bytes from the mapped file. The requested bytes are copied to the destination buffer.

Parameters:
_pvBufferBuffer where to store the read bytes. Must be at least _ui32Total in length.
_ui64OffsetOffset in the file from which to read the bytes.
_ui32TotalTotal bytes to read.
Returns:
Returns the actual number of bytes read.
LSVOID LSE_CALL lsf::CFileMap::Reset ( )

Close the mapped file and discard all allocated resources.

LSUINT32 LSE_CALL lsf::CFileMap::WriteBytes ( const LSUINT8 *  _pui8Buffer,
LSUINT64  _ui64Offset,
LSUINT32  _ui32Total 
)

Write bytes to the mapped file. File must have been mapped with writing permissions.

Parameters:
_pui8BufferSource buffer. Must be at least _ui32Total in length.
_ui64OffsetOffset in the file at which to write the bytes.
_ui32TotalTotal bytes to write.
Returns:
Returns the actual number of bytes written.

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator