Large files in C++
More specifically, wxWidgets and MSVC++ 2010. I found an msdn query that says 2010 is the first version that supports >2Gb file sizes with std::iostream. So that's fine with me. We found a few necessary changes:
Very strange.
- stat() changes to _stat64()
- istream::tellg() returns an istream::streampos, not an int.
// save the beginning position of this line for when we have to back upHow does the commented line with the seekg() fail? It should treat begin_line_pos as an offset, which should be 64 bit. It's REALLY LAME if it sees the unsigned streampos and converts it to 32 bits for some reason....
istream::streampos begin_line_pos = infile_stream.tellg();
string std_keyword;
infile_stream >> std_keyword;
// bunch of other keyword handling.....
if (keyword == "shape") {
infile_stream.seekg(begin_line_pos);
// Danger! over 2Gb, this turns into negative seek, fails:
//infile_stream.seekg(begin_line_pos, ios::beg);
return true;
}
Very strange.
Comments