Groups | Blog | Home
all groups > visual c libraries > july 2003 >

visual c libraries : fstream tellg, seekg and files > 2GB


Frank
7/3/2003 1:25:43 PM
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.

brettke NO[at]SPAM online.microsoft.com
7/15/2003 6:35:48 PM
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.
dsarma NO[at]SPAM online.microsoft.com
7/24/2003 10:04:57 PM
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.
Christopher Yeleighton
4/28/2005 8:10:17 PM
fwrite should also work, it takes a size_t argument

From http://www.developmentnow.com/g/43_2003_7_0_0_156659/fstream-tellg-seekg-and-files--2GB.htm

Posted via DevelopmentNow.com Groups
AddThis Social Bookmark Button