ADTF
cIndexedFileChanger

Class for changing the extension section of indexed files. More...

Inheritance diagram for cIndexedFileChanger:
[legend]

Public Member Functions

 cIndexedFileChanger ()
 Default constructor.
 
 ~cIndexedFileChanger ()
 Destructor.
 
tResult Open (const cString &strFilename, tInt nCacheSize=-1, tUInt32 ui32Flags=0)
 This function opens a dat-file for reading. More...
 
tResult ReplaceExtension (const tChar *strIdentifier, cString &strExtension)
 Replaces the extension data with the new content. More...
 
tResult WriteExtensions ()
 Writes the changed extensions to the datfile which was passed with Open() More...
 
- Public Member Functions inherited from cIndexedFileReader
 A_UTILS_DEPRECATED_MESSAGE ("The class 'cIndexedFileReader' is deprecated. Please use the aquivalent from the " "adtf_file library instead.") cIndexedFileReader()
 Default constructor.
 
 ~cIndexedFileReader ()
 Destructor.
 
virtual tResult Close ()
 This function closes all. More...
 
tResult Reset ()
 This function resets the file to the beginning of data. More...
 
tInt64 GetCurrentPos (tInt nTimeFormat)
 This function returns the current file position (Index or TimeStamp) More...
 
tInt64 SetCurrentPos (tInt64 nPosition, tInt nTimeFormat)
 This function sets the file position. More...
 
tInt64 Seek (tUInt16 ui16StreamId, tInt64 nPosition, tInt nTimeFormat, tUInt32 ui32Flags=0)
 This function sets the new file position and returns the new chunk index or -1 in case the chunk can not be found (for example stream Id is invalid or file position is out of range). More...
 
tResult QueryChunkInfo (tChunkHeader **ppChunkHeader)
 This function returns the ChunkInfo of the current chunk. More...
 
tResult ReadChunk (tVoid **ppData, tUInt32 ui32Flags=0)
 This function reads and returns the current Chunk and increments the current chunk index. More...
 
tResult SkipChunk ()
 This function skips the next Chunk by incrementing the current chunk index and setting the new FilePosition. More...
 
tResult ReadNextChunk (tChunkHeader **ppChunkHeader, tVoid **ppData, tUInt32 ui32Flags=0, tUInt32 ui32StreamId=0)
 This function reads and returns the current Chunk and ChunkInfo struct and increments the current chunk index. More...
 
tResult SkipChunkInfo ()
 This function increments the current chunk index. More...
 
tResult ReadNextChunkInfo (tChunkHeader **ppChunkHeader)
 This function gets the next chunk information. More...
 
tInt64 GetFilePos ()
 This function returns the current chunk index. More...
 
tInt64 GetChunkCount ()
 This function returns the number of chunks of the current file. More...
 
tTimeStamp GetDuration ()
 This function returns the duration of the current file [microsec]. More...
 
tUInt32 GetVersionId ()
 This function returns the Version Id of the current file. More...
 
tTimeStamp GetTimeOffset ()
 This function returns the Time Zero Point Offset every Time is referring to. More...
 
tInt64 GetStreamTableIndexCount (tUInt16 ui16StreamId)
 This function gets the number of indices of the given stream. More...
 
tInt64 GetStreamIndexCount (tUInt16 ui16StreamId)
 This function gets the number of chunks of the given stream. More...
 
tResult GetAdditionalStreamInfo (tUInt16 ui16StreamId, const tVoid **pInfoData, tUInt *pnInfoSize)
 This function gets the additional stream information data of the given stream. More...
 
const tCharGetStreamName (tUInt16 ui16StreamId)
 This function gets the stream name which is set. More...
 
tTimeStamp GetFirstTime (tUInt16 ui16StreamId)
 This function gets the first time stamp of the given stream. More...
 
tTimeStamp GetLastTime (tUInt16 ui16StreamId)
 This function gets the last time stamp of the given stream. More...
 
tInt GetExtensionCount ()
 Get the amount of extensions in the file. More...
 
tResult FindExtension (const tChar *strIdentifier, tFileExtension **ppsExtensionInfo, tVoid **ppData)
 This function gets the extension data. More...
 
tResult GetExtension (tInt nIndex, tFileExtension **ppsExtensionInfo, tVoid **ppData)
 This function gets the extension data. More...
 
tInt64 LookupChunkRef (tUInt16 ui16StreamId, tInt64 nPosition, tInt nTimeFormat)
 This function gets the chunk index of the given file position. More...
 
- Public Member Functions inherited from cIndexedFile
 cIndexedFile ()
 Default constructor.
 
virtual ~cIndexedFile ()
 Destructor.
 
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 Member Functions

tResult FindExtension (const tChar *strIdentifier, tFileExtensionStruct **ppsExtensionStruct)
 In difference to the existing FindExtension methods, this method will return the whole tFileExtensionStruct and not only the members of it. More...
 
- Protected Member Functions inherited from cIndexedFileReader
virtual tResult Initialize ()
 Initializes the reader. More...
 
tResult ReadFileHeader ()
 Reads and initializes the Header struct. More...
 
tResult ReadFileHeaderExt ()
 Reads and initializes the ExtendedHeader. More...
 
tResult ReadIndexTable ()
 Initializes the IndexTable. More...
 
tResult ReadCurrentChunkHeader ()
 Reads the next chunk header.
 
tResult ReadCurrentChunkData (tVoid *pBuffer)
 Reads the data of the current chunk.
 
tResult SetEOF ()
 Set the end of file indication. More...
 
tResult ReadDataBlock (tVoid *pvBuffer, long nBufferSize)
 Reads a raw data block from the file. More...
 
tResult ClearCache ()
 Resets the cache.
 
tResult CheckFilePtr ()
 Checks whether the current position in the file is valid. More...
 
tResult AllocReadBuffers ()
 Initializes the internal read buffers.
 
tResult FreeReadBuffers ()
 Releases the internal read buffers.
 
- Protected Member Functions inherited from cIndexedFile
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...
 

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...
 
- Protected Types inherited from cIndexedFile
typedef std::list< tFileExtensionStruct * > tFileExtensionList
 own type definition for a better work with file extension lists
 
- Protected Attributes inherited from cIndexedFileReader
tInt m_nCacheOffset
 For internal use only (will be moved to a private implementation).
 
tInt m_nCacheUsage
 For internal use only (will be moved to a private implementation).
 
- Protected Attributes inherited from cIndexedFile
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 inherited from cIndexedFile
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.
 

Detailed Description

Class for changing the extension section of indexed files.

Example usage:

RETURN_IF_FAILED(oFC.Open(strDatFileName));
RETURN_IF_FAILED(oFC.ReplaceExtension("marker_info", strExtension));
RETURN_IF_FAILED(oFC.WriteExtensions());
RETURN_IF_FAILED(oFC.Close());
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
cIndexedFileChanger()
Default constructor.

Definition at line 26 of file indexedfilechanger.h.

Member Function Documentation

◆ FindExtension()

tResult FindExtension ( const tChar strIdentifier,
tFileExtensionStruct **  ppsExtensionStruct 
)
protected

In difference to the existing FindExtension methods, this method will return the whole tFileExtensionStruct and not only the members of it.

Parameters
strIdentifier[in] The extension identifier
ppsExtensionStruct[out] Pointer to the pointer which receives the ExtensionStruct address.
Return values
ERR_INVALID_ARGif strIdentifier is nullptr or empty
ERR_POINTERif ppsExensionStruct is nullptr
ERR_UNEXPECTEDif the extension info structure is corrupted
ERR_NOTFOUNDif the extension with the given id does not exist
ERR_NOERRORif succeeded

◆ Open()

tResult Open ( const cString strFilename,
tInt  nCacheSize = -1,
tUInt32  ui32Flags = 0 
)
virtual

This function opens a dat-file for reading.

Since the cIndexFileChanger must write to the file also, it appends the new OM_FileChangeMode flag. This flag enables the ReadWrite Mode while opening.

Parameters
strFilename[in] the file name to be opened
nCacheSize[in] cache size; <=0: use system file caching (=default)
ui32Flags[in] a tOpenMode value
Returns
result from cIndexedFileReader::Open

Reimplemented from cIndexedFileReader.

◆ ReplaceExtension()

tResult ReplaceExtension ( const tChar strIdentifier,
cString strExtension 
)

Replaces the extension data with the new content.

Parameters
strIdentifier[in] The extension identifier which is to be replaced
strExtension[in] the the extension content
Returns
Possible errors from FindExtension()
Possible errors from AllocExtensionPage()
Return values
ERR_NOERRORif succeeded

◆ WriteExtensions()

tResult WriteExtensions ( )

Writes the changed extensions to the datfile which was passed with Open()

Return values
ERR_NOERRORif succeeded, otherwise any error from the called methods