MAK Data Logger API Documentation for HLA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Static Public Member Functions
MAKLogger::DtLargeFileFunctions Class Reference

Provides an interface for large (64bit) File IO. More...

Static Public Member Functions

static DtFileDesc openForReading (const DtFilename &filename, bool randomAccess)
 Open a file for reading.
static DtFileDesc openForWriting (const DtFilename &filename, bool truncate=true)
 Open a file for writing.
static DtFileDesc openForReadingAndWriting (DtFilename filename, bool truncate=false, bool randomAccess=true)
 Open a file for reading and writing.
static bool close (DtFileDesc)
 Closes the file.
static DtInt64 size (DtFileDesc)
 Gets the size of the file in bytes.
static DtInt64 tell (DtFileDesc)
 Get the current position in the file.
static DtInt64 seekCurrent (DtFileDesc, DtInt64)
 Set the current position relative to it's current position.
static DtInt64 seekEnd (DtFileDesc, DtInt64)
 Set the current position relative to the end of the file.
static DtInt64 seekSet (DtFileDesc, DtInt64)
 Set the current position relative to the beginning of the file.
static size_t read (DtFileDesc, void *buffer, size_t bytesToRead)
 Read data from the file into the supplied buffer.
template<typename T >
static bool readStruct (DtFileDesc fd, T &structObject)
 Read a structure from the file.
static char * readBytes (DtFileDesc, size_t bytesToRead, size_t &totalBytesRead)
 Read data into a newly created buffer.
static size_t write (DtFileDesc, const void *buffer, size_t bytesToWrite)
 Write the data from the buffer into the file.
template<typename T >
static bool writeStruct (DtFileDesc fd, const T &structObject)
 Write a structure to the file.

Detailed Description

Provides an interface for large (64bit) File IO.

Warning
For all functions that can fail, use errno an perror to get reason.

Member Function Documentation

static bool MAKLogger::DtLargeFileFunctions::close ( DtFileDesc  )
static

Closes the file.

Return values
trueThe close succeeded.
falseThe close failed.
static DtFileDesc MAKLogger::DtLargeFileFunctions::openForReading ( const DtFilename &  filename,
bool  randomAccess 
)
static

Open a file for reading.

Returns
Returns a file description.
Return values
0Unable to open file for reading.
static DtFileDesc MAKLogger::DtLargeFileFunctions::openForReadingAndWriting ( DtFilename  filename,
bool  truncate = false,
bool  randomAccess = true 
)
static

Open a file for reading and writing.

Returns
Returns a file description.
Return values
0Unable to open file for reading and writing.
static DtFileDesc MAKLogger::DtLargeFileFunctions::openForWriting ( const DtFilename &  filename,
bool  truncate = true 
)
static

Open a file for writing.

Returns
Returns a valid file description.
Return values
0Unable to open file for writing.
static size_t MAKLogger::DtLargeFileFunctions::read ( DtFileDesc  ,
void *  buffer,
size_t  bytesToRead 
)
static

Read data from the file into the supplied buffer.

Returns
Returns the number of bytes actually read.
Warning
This function is dangerous since buffer may not be large enough. Use readBytes for safer access. Also if the file was not opened to support reading this call will return zero.

Referenced by readStruct().

static char* MAKLogger::DtLargeFileFunctions::readBytes ( DtFileDesc  ,
size_t  bytesToRead,
size_t &  totalBytesRead 
)
static

Read data into a newly created buffer.

Returns
Returns a pointer to the data. This data will be allocated on the heap.
Return values
NULLIf the file does not support reading.
Warning
The buffer will contain undefined data after totalBytesRead bytes into the buffer if totalBytesRead != bytesToRead.
template<typename T >
static bool MAKLogger::DtLargeFileFunctions::readStruct ( DtFileDesc  fd,
T &  structObject 
)
inlinestatic

Read a structure from the file.

This function assumes the file data maps directly into the structure. This function will also work with built-in types.

Returns
Whether the read was successful.
Warning
If the read is not successful the object may not be in a complete state.

References read().

static DtInt64 MAKLogger::DtLargeFileFunctions::seekCurrent ( DtFileDesc  ,
DtInt64   
)
static

Set the current position relative to it's current position.

Returns
Returns the position in the file relative to beginning.
static DtInt64 MAKLogger::DtLargeFileFunctions::seekEnd ( DtFileDesc  ,
DtInt64   
)
static

Set the current position relative to the end of the file.

Returns
Returns the position in the file relative to beginning.
static DtInt64 MAKLogger::DtLargeFileFunctions::seekSet ( DtFileDesc  ,
DtInt64   
)
static

Set the current position relative to the beginning of the file.

Returns
Returns the position in the file relative to beginning.
static DtInt64 MAKLogger::DtLargeFileFunctions::size ( DtFileDesc  )
static

Gets the size of the file in bytes.

static DtInt64 MAKLogger::DtLargeFileFunctions::tell ( DtFileDesc  )
static

Get the current position in the file.

static size_t MAKLogger::DtLargeFileFunctions::write ( DtFileDesc  ,
const void *  buffer,
size_t  bytesToWrite 
)
static

Write the data from the buffer into the file.

Returns
Returns the number of bytes written.
Warning
This function is dangerous since buffer may not be bytesToWrite.

Referenced by writeStruct().

template<typename T >
static bool MAKLogger::DtLargeFileFunctions::writeStruct ( DtFileDesc  fd,
const T &  structObject 
)
inlinestatic

Write a structure to the file.

This function assumes the file data maps directly into the structure. This function will also work with built-in types.

Warning
If the read is not successful the file may not be in a valid state. To solve this problem store the previous position and the position after the write to calculate the number of bytes written.

References write().


The documentation for this class was generated from the following file:

Document ID: Generated on Thu Jul 23 15:05:27 EDT 2020 from SVN revision 215371
Copyright © 2020 MAK Technologies. All Rights Reserved (www.mak.com)