//Initialize error_code
error_code = 0;
//Get the file size
DWORD dwBSize = MyFileOps.get_file_size(ThisFile);
//Check for minimimum file size
if(dwBSize < MIN_RAW_SIZE) {error_code = -1; return 0;}
//Declare the buffer that will hold the raw file info
unsignedchar *rBuffer = NULL;
//Allocate memory to rBuffer
rBuffer = new (nothrow) unsignedchar[dwBSize];
if(NULL == rBuffer) {error_code = -2; return 0;}
//Load the file into memory
if(!MyFileOps.load_file(ThisFile, rBuffer, dwBSize))
{
delete [] rBuffer; rBuffer = NULL;
error_code = -3;
return 0;
}
The program returns with error_code = -2; meaning it could not allocate memory to the buffer. I made a class that is associated with all file transactions; such as determining the file size using "GetFileSize", reading the file using "ReadFile." The code above is for a GUI interface with classes. I re-wrote the program with a traditional DOS interface using the same WIN API functions, but without a class and was able to read the file (although it took some time). Any help is greatly appreciated.
I could be wrong, but I don't think there's really any way to allocate that much memory in one block, there's only so much you can keep on one contiguous section.