ADTF
cIndexedFile

Base class for all indexed file classes. More...

Inheritance diagram for cIndexedFile:
[legend]

Classes

struct  tFileExtensionStruct
 combines a file extension information with a concrete extension page More...
 

Public Member Functions

 cIndexedFile ()
 Default constructor.
 
virtual ~cIndexedFile ()
 Destructor.
 
virtual tResult Close ()
 Closes the file. More...
 
tResult SetDescription (const tChar *strDescription)
 Sets the description of the file. More...
 
const tCharGetDescription () const
 Returns the description of the file. More...
 
tResult GetGUID (cString &strGUID)
 Get the GUID of the file. More...
 
tResult SetDateTime (const tDateTime *psDateTime)
 Set the timestamp of the file. More...
 
tResult GetDateTime (tDateTime *psDateTime)
 Get the timestamp of the file. More...
 
tUInt8 GetByteOrder ()
 Returns the byteorder of the file. More...
 
tInt GetExtensionCount ()
 Get the amount of extensions in the file. More...
 
tResult FindExtension (const tChar *strIdentifier, tFileExtension **ppsExtensionInfo, tVoid **ppData)
 Finds an extension with a specific identifier. More...
 
tResult GetExtension (tInt nIndex, tFileExtension **ppsExtensionInfo, tVoid **ppData)
 Get an extension with a specific index. More...
 
tResult AppendExtension (const tChar *strIdentifier, const tVoid *pData, tInt nDataSize, tUInt32 ui32TypeId=0, tUInt32 ui32VersionId=0, tUInt16 ui16StreamId=0, tUInt32 ui32UserId=0)
 Adds a new extension to the file. More...
 
tResult AppendExtension (const tVoid *pData, const tFileExtension *psExtensionInfo)
 Adds a new extension to the file. More...
 
tResult FreeExtension (const tChar *strIdentifier)
 Frees specific extensions. More...
 
tResult FreeExtensions ()
 Frees all extensions. More...
 
tResult GetHeader (tFileHeader **ppsFileHeader)
 Returns the file header. More...
 

Protected Types

typedef std::list< tFileExtensionStruct * > tFileExtensionList
 own type definition for a better work with file extension lists
 

Protected Member Functions

virtual tResult Initialize ()
 Initializes internal data.
 
tResult AllocBuffer (tInt64 nSize)
 Allocates an internal buffer. More...
 
tResult FreeBuffer ()
 Releases the internal buffer.
 
tResult AllocHeader ()
 Allocates the header structure/data.
 
tResult FreeHeader ()
 Releases the header data.
 
tResult AllocExtensionPage (tFileSize nSize, tVoid **ppData)
 Allocate memory for an extension. More...
 
tResult SetGUID ()
 Sets the GUID of the file. More...
 
tResult GenerateNewGUID (cString &strGeneratedGUID)
 Generates a new GUID (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) More...
 
tResult AllocCache (tInt64 nSize)
 Initialzes an internal cache. More...
 
tResult FreeCache ()
 Releases the cache.
 
tVoidGetCacheAddr ()
 Returns the cache pointer.
 
tInt GetSectorSize (const tChar *strFilename) const
 Get the sector size of the filesystem that a specified file resides on. More...
 
tFileSize GetSizeOnDisk (tFileSize nSize, tBool bUseSegmentSize)
 Calculates the size a data block requires on disk. More...
 
tVoidInternalMalloc (tInt64 nSize, tBool bUseSegmentSize)
 Allocates memory. More...
 
tVoid InternalFree (tVoid *pMemory)
 Release memory. More...
 

Protected Attributes

tInt64 m_nSectorSize
 current sector size used for disk device depend on drive given by filename within Create method of cIndexedFileReader or cIndexFileWriter
 
tBool m_bSystemCacheDisabled
 whether system cache used or not depend on flags given within Create method of cIndexedFileReader or cIndexFileWriter
 
cFile m_oFile
 the open file
 
tFilePos m_nFilePos
 current filepos
 
tUInt8m_pBuffer
 internal Buffer
 
tInt64 m_nBufferSize
 internal Buffer size
 
tFileHeaderm_psFileHeader
 current file header
 
tBool m_bWriteGUID
 protection for writing GUID
 
tFileExtensionList m_lstExtensions
 list with all extensions
 
tVoidm_pCache
 cache data area
 
tInt64 m_nCacheSize
 size of cache
 
tBool m_bWriteMode
 For internal use only (will be moved to a private implementation).
 

Static Protected Attributes

static const tUInt32 m_nFileId
 For internal use only (will be moved to a private implementation).
 
static const tUInt32 m_nVersionId
 supported Version of Indexed File within ADTF 2.0 until 2.12 and >= 2.13 if NO History is used while writing file (currently 0x00000201)
 
static const tUInt32 m_nVersionIdWithHistory
 supported Version of Indexed File within >= ADTF 2.13 if a file buffered history is used while writing file (currently 0x00000300)
 
static const tUInt32 m_nVersionIdWithHistoryEndOffset
 supported Version of Indexed File within >= ADTF 2.13.1 if a file buffered history is used while writing file (currently 0x00000301)
 
static const tUInt32 m_nVersionADTF3
 supported Version of Indexed File within >= ADTF 3.0.0 (currently 0x00000301)
 
static const tUInt8 m_ui8ByteOrder
 current value of platform ByteOrder ( More...
 
static tInt64 m_nDefaultBlockSize
 Default block size in bytes.
 
static tInt64 m_nDefaultCacheSize
 Default cache size in bytes.
 

Additional Inherited Members

- Public Types inherited from IIndexedFile
enum  tTimeFormat { TF_ChunkIndex = 1 , TF_ChunkTime = 2 , TF_StreamIndex = 3 }
 Time format (for seek etc.) More...
 
enum  tReadFlags { RF_None = 0x0 , RF_UseExternalBuffer = 0x1 , RF_Backwards = 0x2 }
 Read options.
 
enum  tSeekFlags { SF_DEFAULT = 0x0 , SF_KEYDATA = 0x1 , SF_BEFORE = 0x02 }
 Seek flags. More...
 
enum  tChunkType {
  CT_DATA = 0x00 , CT_KEYDATA = 0x01 , CT_INFO = 0x02 , CT_MARKER = 0x04 ,
  CT_TYPE = 0x08 , CT_TRIGGER = 0x10
}
 The chunk types. More...
 
enum  tOpenMode {
  OM_None = 0x00 , OM_DisableFileSystemCache = 0x01 , OM_SyncWrite = 0x02 , OM_QueryInfo = 0x04 ,
  OM_ValidateChunkHeader = 0x08 , OM_FileChangeMode = 0x10
}
 File open modes. More...
 

Detailed Description

Base class for all indexed file classes.

FILE LAYOUT for Version 2.0.1


+----------------------------------------------------------------------------------—+
|HDR| DATA | EXTENSIONS | EXTENSIONSHEADER-HDR |
+----------------------------------------------------------------------------------—+


FILE LAYOUT for Version 2.0.2


+-----------------------------------------------------------------------------------------------—+
|HDR| QUEUED HISTORY CHUNK DATA | SORTED CHUNK DATA | EXTENSIONS | EXTENSIONSHEADER-HDR |
+-----------------------------------------------------------------------------------------------—+


Special Extensions to provide:
  • GUUID within the File
  • MASTER Index Table
  • Stream Index Tables

Definition at line 73 of file indexedfile.h.

Member Function Documentation

◆ AllocBuffer()

tResult AllocBuffer ( tInt64  nSize)
protected

Allocates an internal buffer.

Parameters
[in]nSizeThe size in bytes to allocate.
Returns
Standard result.

◆ AllocCache()

tResult AllocCache ( tInt64  nSize)
protected

Initialzes an internal cache.

Parameters
[in]nSizeThe size of the cache.
Returns
Standard result.

◆ AllocExtensionPage()

tResult AllocExtensionPage ( tFileSize  nSize,
tVoid **  ppData 
)
protected

Allocate memory for an extension.

Parameters
[in]nSizeThe amount of bytes to allocate.
[out]ppDataPointer to the allocated space.
Returns
Standard result.

◆ AppendExtension() [1/2]

tResult AppendExtension ( const tChar strIdentifier,
const tVoid pData,
tInt  nDataSize,
tUInt32  ui32TypeId = 0,
tUInt32  ui32VersionId = 0,
tUInt16  ui16StreamId = 0,
tUInt32  ui32UserId = 0 
)

Adds a new extension to the file.

Warning
The extension 'GUID' is protected and could not be overwritten
Parameters
strIdentifier[in] The identifier of the extension.
pData[in] The extension data.
nDataSize[in] The data size.
ui32TypeId[in] An optional type id
ui32VersionId[in] An optional version id
ui16StreamId[in] An optional stream id
ui32UserId[in] An optional user id
Returns
Standard result.

◆ AppendExtension() [2/2]

tResult AppendExtension ( const tVoid pData,
const tFileExtension psExtensionInfo 
)

Adds a new extension to the file.

Warning
The extension 'GUID' is protected and could not be overwritten
Parameters
pData[in] The extension data.
psExtensionInfo[in] The extension info.
Returns
Standard result.

◆ Close()

virtual tResult Close ( )
virtual

Closes the file.

Returns
Standard result.

Reimplemented in cIndexedFileWriter, and cIndexedFileReader.

◆ FindExtension()

tResult FindExtension ( const tChar strIdentifier,
tFileExtension **  ppsExtensionInfo,
tVoid **  ppData 
)

Finds an extension with a specific identifier.

Parameters
strIdentifier[in] The identifier of the extension
ppsExtensionInfo[out] The extension info data.
ppData[out] The extension data.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ FreeExtension()

tResult FreeExtension ( const tChar strIdentifier)

Frees specific extensions.

Parameters
strIdentifier[in] the specific extension.
Returns
Standard result.

◆ FreeExtensions()

tResult FreeExtensions ( )

Frees all extensions.

Returns
Standard result.

◆ GenerateNewGUID()

tResult GenerateNewGUID ( cString strGeneratedGUID)
protected

Generates a new GUID (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)

Parameters
strGeneratedGUID[out] new generated GUID
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetByteOrder()

tUInt8 GetByteOrder ( )

Returns the byteorder of the file.

Returns
PLATFORM_LITTLE_ENDIAN_8 or PLATFORM_BIG_ENDIAN_8
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetDateTime()

tResult GetDateTime ( tDateTime psDateTime)

Get the timestamp of the file.

Parameters
psDateTime[out] The timestamp of the file.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetDescription()

const tChar* GetDescription ( ) const

Returns the description of the file.

Returns
The description of the file.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetExtension()

tResult GetExtension ( tInt  nIndex,
tFileExtension **  ppsExtensionInfo,
tVoid **  ppData 
)

Get an extension with a specific index.

Parameters
nIndex[in] The index of the extension.
ppsExtensionInfo[out] The extension info data.
ppData[out] The extension data.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetExtensionCount()

tInt GetExtensionCount ( )

Get the amount of extensions in the file.

Returns
The amount of extensions in the file.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetGUID()

tResult GetGUID ( cString strGUID)

Get the GUID of the file.

Parameters
strGUID[out] the GUID of the file
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetHeader()

tResult GetHeader ( tFileHeader **  ppsFileHeader)

Returns the file header.

Parameters
ppsFileHeader[out] Will point to the file header.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetSectorSize()

tInt GetSectorSize ( const tChar strFilename) const
protected

Get the sector size of the filesystem that a specified file resides on.

Parameters
strFilename[in] The filename.
Returns
The sector size.

◆ GetSizeOnDisk()

tFileSize GetSizeOnDisk ( tFileSize  nSize,
tBool  bUseSegmentSize 
)
protected

Calculates the size a data block requires on disk.

Parameters
[in]nSizeThe size of the data block.
[in]bUseSegmentSizeInclude the segment size into the calculation.
Returns
The calculated size.

◆ InternalFree()

tVoid InternalFree ( tVoid pMemory)
protected

Release memory.

Parameters
[in]pMemoryThe memory which should be free'd.
Returns
void

◆ InternalMalloc()

tVoid* InternalMalloc ( tInt64  nSize,
tBool  bUseSegmentSize 
)
protected

Allocates memory.

Parameters
[in]nSizeThe size of the data block.
[in]bUseSegmentSizeWhether or not to align the memory on segment boundaries.
Returns
Pointer to the allocated space.

◆ SetDateTime()

tResult SetDateTime ( const tDateTime psDateTime)

Set the timestamp of the file.

The timestamp is calculated from the passed date/time structure while the current time zone from the system is used.

Parameters
psDateTime[in] The new date/time for the timestamp.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SetDescription()

tResult SetDescription ( const tChar strDescription)

Sets the description of the file.

Parameters
strDescription[in] The new description.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SetGUID()

tResult SetGUID ( )
protected

Sets the GUID of the file.

Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

Member Data Documentation

◆ m_ui8ByteOrder

const tUInt8 m_ui8ByteOrder
staticprotected

current value of platform ByteOrder (

See also
PLATFORM_BYTEORDER)

Definition at line 92 of file indexedfile.h.