|
|
|
|
|
|
|
|
ifstream CFGFile(FileName.c_str()); // Open the file. |
|
|
ifstream CFGFile(FileName.c_str()); // Open the file. |
|
|
CFGFile.seekg(0,ios::end); // Seek to the end |
|
|
CFGFile.seekg(0,ios::end); // Seek to the end |
|
|
myBufferSize = CFGFile.tellg(); // to find out what size it is. |
|
|
myBufferSize = CFGFile.tellg(); // to find out what size it is. |
|
|
myDataBuffer = new char[myBufferSize]; // Make a new buffer the right size. |
|
|
|
|
|
|
|
|
myDataBuffer = new char[myBufferSize + 1]; // Make a new buffer the right size, |
|
|
|
|
|
// including null byte at end. |
|
|
CFGFile.seekg(0,ios::beg); // Seek to the beginning and |
|
|
CFGFile.seekg(0,ios::beg); // Seek to the beginning and |
|
|
CFGFile.read(myDataBuffer, myBufferSize); // read the file into the buffer. |
|
|
CFGFile.read(myDataBuffer, myBufferSize); // read the file into the buffer. |
|
|
|
|
|
myDataBuffer[myBufferSize] = '\0'; // Null-terminate. |
|
|
if(CFGFile.bad()) { // If the read failed, we're unusable! |
|
|
if(CFGFile.bad()) { // If the read failed, we're unusable! |
|
|
delete[] myDataBuffer; // Delete the buffer |
|
|
delete[] myDataBuffer; // Delete the buffer |
|
|
myDataBuffer = NULL; // and Null it's pointer. |
|
|
myDataBuffer = NULL; // and Null it's pointer. |