ADTF
|
File class. More...
Public Types | |
enum | tOpenMode { OM_Read = 0x0001 , OM_Write = 0x0002 , OM_Append = 0x0004 , OM_ReadWrite = 0x0008 , OM_SharedRead = 0x0100 , OM_SharedWrite = 0x0200 , OM_SequentialAccess = 0x0400 , OM_TemporaryFile = 0x0800 , OM_ShortLived = 0x1000 , OM_TextMode = 0x2000 , OM_WriteThrough = 0x4000 , OM_DisableFileSystemCache = 0x8000 } |
Several flags to open files. Can be combined with bitwise or. More... | |
enum | tFilePosRef { FP_Begin = 0 , FP_Current = 1 , FP_End = 2 } |
File position reference. More... | |
Public Member Functions | |
cFile () | |
Constructor. | |
virtual | ~cFile () |
Destructor. If handling an open file, the file is closed. | |
tResult | Open (const cFilename &strFilename, tUInt32 ui32Mode) |
This function opens an existing or creates a new file. More... | |
tResult | Close () |
Close file. More... | |
tResult | Attach (cFile &oFile) |
This function attaches an existing instance of a file class to another. More... | |
tResult | Detach () |
This function detaches existing references to file objects. More... | |
tBool | SetReadCache (tInt nCacheSize) |
This function sets the file read cache size. More... | |
tInt | Read (tVoid *pvBuffer, tInt nBufferSize) |
This function reads data into a buffer from the file associated with the cFile object. More... | |
tResult | ReadAll (tVoid *pvBuffer, tInt nBufferSize) |
This function reads data into a buffer from the file associated with the cFile object. More... | |
tInt | Skip (tInt nNumberOfBytes) |
This function reads data from a file but does not store it . More... | |
tInt | Write (const tVoid *pvBuffer, tInt nBufferSize) |
This function writes data from a buffer to the file associated with the cFile object. More... | |
tResult | WriteAll (const tVoid *pvBuffer, tInt nBufferSize) |
This function writes data from a buffer to the file associated with the cFile object. More... | |
tInt | Write (const cString &strString) |
This function writes string data from a buffer to the file associated with the cFile object. More... | |
tInt | ReadLine (cString &strString) |
This function reads a line of text data into a cString object. More... | |
tInt | WriteLine (const cString &strString) |
This function writes string data from a buffer to the file associated with the cFile object. More... | |
tFileSize | GetSize () const |
This function retrieves the file size. More... | |
tFilePos | GetFilePos () const |
This function retrieves the file pointer offset. More... | |
tFilePos | SetFilePos (tFilePos nOffset, tFilePosRef MoveMode) |
This function moves the file pointer. More... | |
tBool | IsEof () |
Checks whether or not the end of the file has been reached. More... | |
tBool | IsValid () const |
This function checks if the file object has an valid file handle. More... | |
tResult | Truncate (tFilePos nSize) |
This method truncates the file at the given size. More... | |
Static Public Member Functions | |
static tResult | GetTimeAccess (const cFilename filename, A_UTILS_NS::cDateTime &dt) |
This function returns the last access time of the file. More... | |
static tResult | GetTimeCreation (const cFilename filename, A_UTILS_NS::cDateTime &dt) |
This function returns the creation time of the file. More... | |
static tResult | GetTimeChange (const cFilename filename, A_UTILS_NS::cDateTime &dt) |
This function returns the last change (write) time of the file. More... | |
Protected Member Functions | |
tVoid | Initialize () |
Initialization. | |
tResult | AllocReadCache (tInt nCacheSize) |
Allocate read cache. More... | |
tResult | FreeReadCache () |
Free read cache. More... | |
tVoid * | InternalMalloc (tInt nSize, tBool bUseSegmentSize=tFalse) |
Internal allocation method. More... | |
tVoid | InternalFree (tVoid *pMemory, tBool bUseSegmentSize=tFalse) |
Internal free method. More... | |
Protected Attributes | |
tFileHandle | m_hFile |
File handle. | |
tUInt8 * | m_pReadCache |
File read cache. | |
tInt | m_nFileCacheUsage |
File cache usage. | |
tInt | m_nFileCacheOffset |
File cache offset. | |
tInt | m_nFileCacheSize |
File cache size. | |
tBool | m_bReadCacheEnabled |
Read cache enabled. | |
tBool | m_bReference |
File is reference. | |
tBool | m_bSystemCacheDisabled |
System cache disabled. | |
tInt | m_nSectorSize |
Sector size. | |
tFilePos | m_nSectorBytesToSkip |
Sector bytes that will be skipped. | |
enum tFilePosRef |
enum tOpenMode |
Several flags to open files. Can be combined with bitwise or.
Allocate read cache.
nCacheSize | [in] Size of cache. |
This function attaches an existing instance of a file class to another.
oFile | [in] Reference to an existing file object. |
tResult Close | ( | ) |
Close file.
Standard | error code. |
is | always ERR_NOERROR. |
tResult Detach | ( | ) |
This function detaches existing references to file objects.
|
protected |
Free read cache.
tFilePos GetFilePos | ( | ) | const |
This function retrieves the file pointer offset.
Referenced by cFileRingBuffer< ADDITIONAL_DATA, ALIGNMENT >::StartAppending().
tFileSize GetSize | ( | ) | const |
This function retrieves the file size.
|
static |
This function returns the last access time of the file.
dt | A_UTILS_NS::cDateTime of the last access |
filename | cFilename of the file to be checked |
|
static |
This function returns the last change (write) time of the file.
dt | A_UTILS_NS::cDateTime of the last access |
filename | cFilename of the file to be checked |
|
static |
This function returns the creation time of the file.
dt | A_UTILS_NS::cDateTime of the last access |
filename | cFilename of the file to be checked |
Internal free method.
pMemory | [in] Pointer to memory. |
bUseSegmentSize | [in] Keep segment size in mind. |
Internal allocation method.
nSize | [in] Size of cache. |
bUseSegmentSize | [in] Keep segment size in mind. |
tBool IsEof | ( | ) |
Checks whether or not the end of the file has been reached.
tBool IsValid | ( | ) | const |
This function checks if the file object has an valid file handle.
This function opens an existing or creates a new file.
strFilename | [in] string that is the path to the desired file. The path can be relative, absolute, or a network name (UNC). tUInt32 Mode: A tUInt32 that defines the file sharing and access mode. It specifies the action to take when opening the file. You can combine options by using the bitwise-OR ( | ) operator. |
ui32Mode | [in] File open mode. For valid flags see the tOpenMode enum. |
Standard | error code. |
ERR_OPEN_FAILED | Could not read file from hard drive. |
ERR_INVALID_FLAGS | Invalid file open mode ui32Mode . |
ERR_NOACCESS | Could not set read cache. |
ERR_NOERROR | if succeeded. |
This function reads data into a buffer from the file associated with the cFile object.
pvBuffer | [in] Pointer to the user-supplied buffer that is to receive the data read from the file. |
nBufferSize | [in] The maximum number of bytes to be read from the file. For text-mode files, carriage return-linefeed pairs are counted as single characters. |
This function reads data into a buffer from the file associated with the cFile object.
It ensures that all requested bytes have been read.
pvBuffer | [in] Pointer to the user-supplied buffer that is to receive the data read from the file. |
nBufferSize | [in] The maximum number of bytes to be read from the file. For text-mode files, carriage return-linefeed pairs are counted as single characters. |
ERR_NOERROR | nBufferSize bytes have been read. |
This function reads a line of text data into a cString object.
strString | [inout] cString object to be filled with character data. |
tFilePos SetFilePos | ( | tFilePos | nOffset, |
tFilePosRef | MoveMode | ||
) |
This function moves the file pointer.
nOffset | [in] Offset value for pointer movement, relative to MoveMode. |
MoveMode | [in] Fixed reference point for movement. |
Referenced by cFileRingBuffer< ADDITIONAL_DATA, ALIGNMENT >::cFileRingBuffer(), cFileRingBuffer< ADDITIONAL_DATA, ALIGNMENT >::AppendItem(), and cFileRingBuffer< ADDITIONAL_DATA, ALIGNMENT >::StartAppending().
This function sets the file read cache size.
nCacheSize | [in] Number of bytes to be allocated as read buffer. If this less than zero, a read cache the size of the default sector size is allocated |
tTrue | if the read cache was allocated |
tFalse | in case of error |
This function reads data from a file but does not store it .
nNumberOfBytes | [in] The maximum number of bytes to be skipped. |
This method truncates the file at the given size.
If the file is larger than the given size, the extra data is lost. If it was smaller it is extended.
nSize |
Referenced by cFileRingBuffer< ADDITIONAL_DATA, ALIGNMENT >::AppendItem().
This function writes string data from a buffer to the file associated with the cFile object.
strString | [in] cString object to be written to the file. |
This function writes data from a buffer to the file associated with the cFile object.
pvBuffer | [in] Pointer to the user-supplied buffer that is to receive the data read from the file. |
nBufferSize | [in] The maximum number of bytes to be read from the file. For text-mode files, carriage return-linefeed pairs are counted as single characters. If nBufferSize is 0, the return value is always 0 and nothing is written. |
This function writes data from a buffer to the file associated with the cFile object.
It ensures that all requested bytes have been written.
pvBuffer | [in] Pointer to the user-supplied buffer that is to receive the data read from the file. |
nBufferSize | [in] The maximum number of bytes to be read from the file. For text-mode files, carriage return-linefeed pairs are counted as single characters. If nBufferSize is 0, the return value is always 0 and nothing is written. |
ERR_NOERROR | nBufferSize bytes have been written. |
Referenced by cFileRingBuffer< ADDITIONAL_DATA, ALIGNMENT >::AppendItem(), and cFileRingBuffer< ADDITIONAL_DATA, ALIGNMENT >::FillForAlignment().
This function writes string data from a buffer to the file associated with the cFile object.
The string is followed by a carriage return-linefeed pair.
strString | [in] cString object to be written to the file. |