S
Sergei Shelukhin
Hi. I have the following problem; VC++ project, there's this code
operation on 500Mb file via ifstream, POS_TYPE for this case is
unsigned int which is 32-bit long.
//dataFile.good() returns 1 here. File is open in binary mode
dataFile.seekg(someValue, ios::beg); // someValue is ~247M
//dataFile.tellg() gives someValue correctly here.
POS_TYPE* dataBuffer = new POS_TYPE[someValue2]; //someValue2 is ~4k
dataFile.read((char*)dataBuffer, someValue2 * sizeof(POS_TYPE));
//at this point, gcount returns 138, bad() gives 0, and eof() and
fail() both return 1.
The interesting thing is that the error is persistent (at least for an
hour while I was debugging this) and occurs at specific locations,
while on others, including the locations closer to the end of file, it
doesn't occur.
I tried copying the file back and forth and it seems to be ok (e.g.
not bad sectors or anything).
What can be causing it? Is there any way to get a more detailed error
message?
operation on 500Mb file via ifstream, POS_TYPE for this case is
unsigned int which is 32-bit long.
//dataFile.good() returns 1 here. File is open in binary mode
dataFile.seekg(someValue, ios::beg); // someValue is ~247M
//dataFile.tellg() gives someValue correctly here.
POS_TYPE* dataBuffer = new POS_TYPE[someValue2]; //someValue2 is ~4k
dataFile.read((char*)dataBuffer, someValue2 * sizeof(POS_TYPE));
//at this point, gcount returns 138, bad() gives 0, and eof() and
fail() both return 1.
The interesting thing is that the error is persistent (at least for an
hour while I was debugging this) and occurs at specific locations,
while on others, including the locations closer to the end of file, it
doesn't occur.
I tried copying the file back and forth and it seems to be ok (e.g.
not bad sectors or anything).
What can be causing it? Is there any way to get a more detailed error
message?