I'm using ifstream to read files >2GB, in fact, some are greater than 4GB. I need to be able to work with the "get" position using tellg and seekg methods. I'm using the new <iostream> libraries. Within the ifstream class, tellg (and seekg) won't work when the position I'm interested in is beyond the 2GB boundary. The type returned is a long, not an __int64 or long long. After examining the headers, I tried defining WIN64 (even though I'm using 32-bit Windows), thinking that might pull in the larger typedefines. But, then there were conflicting size_t definitions that I couldn't resolve. Is there some simple method of getting support for large files within ifstream? Outside the standard streams library there seems to be several options, making OS calls directly or using tellgi64, but unless I'm missing something, I don't seem the same support for the new streams libraries.
Hi Frank, Thanks for your post. I have sent it on to a colleague and will reply with their answer ASAP. Thanks for your patience, Brett Keown Microsoft Developer Support brettke@nospam.microsoft.com To email me directly, please remove the "nospam" from my email address. This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use. © 2001 Microsoft Corporation. All rights reserved.
Hi Frank, Any file greater than 4 GB can not be read using the fstream class. This is a limitation in the stream i/o functions. If you are interested in the Win32 way, we have detailed documentation on how this works in the SetFilePointer documentation. If you wanted to stick to the non-Win32 options, you could use the lowest i/o we have in the CRT: _open/_read/_write/_lseek/_lseeki64. Thanks. Deba Sarma Microsoft Developer Support This posting is provided AS IS with no warranties, and confers no rights.
Don't see what you're looking for? Try a search.
|