Click to See Complete Forum and Search --> : How std::iostream support file size more than 2G


Pankaj Mongia
February 21st, 2005, 01:10 AM
Is there any way std::iostream support files size more than 2Gb maen to say
64 bit i/o

NoHero
February 22nd, 2005, 02:39 PM
On Win32? Yes, since size_t are explicity defined as __int64. Just use the new STL classes. Or take a look at the WinAPI functions CreateFile(), ReadFile() and/or WriteFile().

Pankaj Mongia
February 27th, 2005, 04:41 AM
Hi NoHero,

My basic concern is we have derived the class from streambuf and we overide the
functions seekoff for fast searching, also we are using funtions tellp and seekg
function. so can there is any way to that we will not lost this functionality any create the file more tha 2 GB. Pls reply soon

NoHero
February 27th, 2005, 05:55 AM
Since the internal type of streambuf streamoff is a long you cannot move further than 2GB at once. So you have to move it 2 GB and than move again from the current position.


Something like: (pseudo code)

1: divide and modulo until you have a small part you can move
2: move
3: repeat step 1 until you are the position