ADTF  3.18.2
cIndexedFileHelper

Helper class to access file information. More...

Public Types

enum  tFieldMask { FM_None = 0x00 , FM_Description = 0x01 , FM_DateTime = 0x02 }
 Mask which fields of the file header should be updated, see cIndexedFileHelper::UpdateHeader .
 

Static Public Member Functions

static tResult GetHeader (const cString &strFilename, IIndexedFile::tFileHeader *psFileHeader)
 Returns the header of a file. More...
 
static tResult UpdateHeader (const cString &strFilename, const IIndexedFile::tFileHeader *psFileHeader, tUInt32 ui32Mask)
 Update header info. More...
 
static tResult QueryFileInfo (const cString &strFilename, cString &strFileInfo)
 Returns the date and the description of a file in a string. More...
 
static tResult QueryFileInfo (const cString &strFilename, cString &strFileInfo, cStringList &lstExtensions)
 Returns the date and the description of a file in a string. More...
 
static tResult CreateChecksumFile (const cFilename &strFilename, cString &strError)
 Creates an MD5 Checksum file for the given DAT file. More...
 
static tResult CheckFile (const cFilename &strFilename, cString &strError, const cFilename &strMD5File="")
 Checks if a DAT file has been corrupted. More...
 
static tResult ExtractAndCheckDatIfNecessary (const cFilename &strFilename, cFilename &strTmpFilename, cString &strError)
 Checks if strFilename is a compressed dat file, extracts it to a temporary location and returns the path to the temporary file in strTmpFilename. More...
 
static tResult GetExtension (const cString &strFilename, const cString &strExtension, IIndexedFile::tFileExtension *psExtensionInfo, tVoid **ppData)
 Return the requested file extension. More...
 
static tResult WriteExtension (const cString &strFilename, IIndexedFile::tFileExtension *psExtensionInfo, const tVoid *pData)
 Write an extension If the extension already exists, it will be overwritten. More...
 
static tResult IsADTFDatfile (const cFilename &strFilename)
 Check if a particular file is a DAT file. More...
 
static tResult Stream2FileHeader (IIndexedFile::tFileHeader *psFileHeader)
 Convert a file header structure to native byte order. More...
 
static tResult Stream2FileHeaderExtension (const IIndexedFile::tFileHeader *psFileHeader, IIndexedFile::tFileExtension *pHeaderExt, tInt nNumExtensions)
 Convert a file header extension structure to native byte order. More...
 
static tResult Stream2ChunkHeader (const IIndexedFile::tFileHeader *psFileHeader, IIndexedFile::tChunkHeader *psChunk)
 Convert a chunk header structure to native byte order. More...
 
static tResult Stream2ChunkRef (const IIndexedFile::tFileHeader *psFileHeader, IIndexedFile::tChunkRef *psChunkRef)
 Convert a chunk reference structure to native byte order. More...
 
static tResult Stream2StreamRef (const IIndexedFile::tFileHeader *psFileHeader, IIndexedFile::tStreamRef *psStreamRef)
 Convert a stream reference structure to native byte order. More...
 
static tResult Stream2StreamInfoHeader (const IIndexedFile::tFileHeader *psFileHeader, IIndexedFile::tStreamInfoHeader *psStreamInfo)
 Convert a stream info header structure to native byte order. More...
 
static tResult Stream2AdditonalIndexInfo (const IIndexedFile::tFileHeader *psFileHeader, IIndexedFile::tAdditionalIndexInfo *psAdditonalIndexInfo)
 Convert a additional stream info structure to native byte order. More...
 

Detailed Description

Helper class to access file information.

Warning
Do not use this class for cross-platform processing of files!
Note
For cross-platform processing use cIndexedFileReader and cIndexedFileWriter .

Definition at line 21 of file indexedfilehelper.h.

Member Function Documentation

◆ CheckFile()

static tResult CheckFile ( const cFilename strFilename,
cString strError,
const cFilename strMD5File = "" 
)
static

Checks if a DAT file has been corrupted.

The check is only performed if an .md5sum file exists, otherwise ERROR_NOERROR is returned.

Parameters
strFilename[in] The name of the DAT file.
strError[out] In case of failure a this will contain a description of the error that occured.
strMD5File[in] Optional filename of an mdsum file.
Returns
Standard result.

◆ CreateChecksumFile()

static tResult CreateChecksumFile ( const cFilename strFilename,
cString strError 
)
static

Creates an MD5 Checksum file for the given DAT file.

Parameters
strFilename[in] The name of the DAT file.
strError[out] In case of failure a this will contain a description of the error that occured.
Returns
Standard result.

◆ ExtractAndCheckDatIfNecessary()

static tResult ExtractAndCheckDatIfNecessary ( const cFilename strFilename,
cFilename strTmpFilename,
cString strError 
)
static

Checks if strFilename is a compressed dat file, extracts it to a temporary location and returns the path to the temporary file in strTmpFilename.

This method caches its earlier results so that the file won't be extracted and checked twice.

If the strFilename is an uncompressed file, the string is passed back unmodified.

Parameters
[in]strFilenameThe input file name.
[out]strTmpFilenameThe name of the temporary file or the strFilename.
[out]strErrorError String if failed.
Returns
Standard result.

◆ GetExtension()

static tResult GetExtension ( const cString strFilename,
const cString strExtension,
IIndexedFile::tFileExtension *  psExtensionInfo,
tVoid **  ppData 
)
static

Return the requested file extension.

You have to release the memory for the return value ppData with delete [] ppData;

Parameters
strFilename[in] The input file name.
strExtension[in] The requested file extension.
psExtensionInfo[out] This will be filled with the file extension information.
ppData[out] This will be filled with the file extension data.
Returns
Standard result.

◆ GetHeader()

static tResult GetHeader ( const cString strFilename,
IIndexedFile::tFileHeader *  psFileHeader 
)
static

Returns the header of a file.

Parameters
strFilename[in] The filename
psFileHeader[out] This will be filled with the information.
Returns
Standard result.

◆ IsADTFDatfile()

static tResult IsADTFDatfile ( const cFilename strFilename)
static

Check if a particular file is a DAT file.

Parameters
strFilename[in] Name of the file to check.
Returns
Standard result.

◆ QueryFileInfo() [1/2]

static tResult QueryFileInfo ( const cString strFilename,
cString strFileInfo 
)
static

Returns the date and the description of a file in a string.

Parameters
strFilename[in] The filename.
strFileInfo[out] The info string.
Returns
Standard result.

◆ QueryFileInfo() [2/2]

static tResult QueryFileInfo ( const cString strFilename,
cString strFileInfo,
cStringList lstExtensions 
)
static

Returns the date and the description of a file in a string.

It will also check if the given extension exits.

Parameters
strFilename[in] The filename.
strFileInfo[out] The info string.
lstExtensions[inout] the list of extensions.
Returns
Standard result.

◆ Stream2AdditonalIndexInfo()

static tResult Stream2AdditonalIndexInfo ( const IIndexedFile::tFileHeader *  psFileHeader,
IIndexedFile::tAdditionalIndexInfo *  psAdditonalIndexInfo 
)
static

Convert a additional stream info structure to native byte order.

Parameters
[in]psFileHeaderThe header
[in]psAdditonalIndexInfoThe additional index info.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ Stream2ChunkHeader()

static tResult Stream2ChunkHeader ( const IIndexedFile::tFileHeader *  psFileHeader,
IIndexedFile::tChunkHeader *  psChunk 
)
static

Convert a chunk header structure to native byte order.

Parameters
[in]psFileHeaderThe header
[in]psChunkThe chunk header.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ Stream2ChunkRef()

static tResult Stream2ChunkRef ( const IIndexedFile::tFileHeader *  psFileHeader,
IIndexedFile::tChunkRef *  psChunkRef 
)
static

Convert a chunk reference structure to native byte order.

Parameters
[in]psFileHeaderThe header
[in]psChunkRefThe chunk reference
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ Stream2FileHeader()

static tResult Stream2FileHeader ( IIndexedFile::tFileHeader *  psFileHeader)
static

Convert a file header structure to native byte order.

Parameters
[in]psFileHeaderThe header
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ Stream2FileHeaderExtension()

static tResult Stream2FileHeaderExtension ( const IIndexedFile::tFileHeader *  psFileHeader,
IIndexedFile::tFileExtension *  pHeaderExt,
tInt  nNumExtensions 
)
static

Convert a file header extension structure to native byte order.

Parameters
[in]psFileHeaderThe header
[in]pHeaderExtThe header extension.
[in]nNumExtensionsThe number of Extensions.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ Stream2StreamInfoHeader()

static tResult Stream2StreamInfoHeader ( const IIndexedFile::tFileHeader *  psFileHeader,
IIndexedFile::tStreamInfoHeader *  psStreamInfo 
)
static

Convert a stream info header structure to native byte order.

Parameters
[in]psFileHeaderThe header
[in]psStreamInfoThe stream info.
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ Stream2StreamRef()

static tResult Stream2StreamRef ( const IIndexedFile::tFileHeader *  psFileHeader,
IIndexedFile::tStreamRef *  psStreamRef 
)
static

Convert a stream reference structure to native byte order.

Parameters
[in]psFileHeaderThe header
[in]psStreamRefThe stream reference
Returns
Standard result.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ UpdateHeader()

static tResult UpdateHeader ( const cString strFilename,
const IIndexedFile::tFileHeader *  psFileHeader,
tUInt32  ui32Mask 
)
static

Update header info.

Parameters
strFilename[in] The filename.
psFileHeader[in] The new header info.
ui32Mask[in] Which fields to update, see cIndexedFileHelper::tFieldMask .
Returns
Standard result.

◆ WriteExtension()

static tResult WriteExtension ( const cString strFilename,
IIndexedFile::tFileExtension *  psExtensionInfo,
const tVoid pData 
)
static

Write an extension If the extension already exists, it will be overwritten.

Warning
The extension 'GUID' is protected and could not be overwritten
Parameters
strFilename[in] The input file name.
psExtensionInfo[in] This will be filled with the file extension information.
pData[in] This will be filled with the file extension data.
Returns
Standard result.