64 Bit Seeking? - IO Stream

I am making a general IO handler for files and devices, but I will be using them on things greater than 4 GB's (0x00000001 00000000) and IOStream's seek's only seek to 32 bit addresses, what ways are there to seek to such a sized address?
Last edited on
My first thought is to increment seek position from current position:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void far_seekg(fstream &file,unsigned long long pos)
{
file.seekg(0,ios::beg); // start from begining

int int32_max= ~((unsigned int)0)/2 ; // max seek position for signed int

while(pos>int32_max)
  {
     file.seekg(int32_max,ios::cur); // notice ios::curr

     pos-=int32_max;
  }

file.seekg(pos,ios::cur);

}

I can't guarantee that this will work (I couldn't find a file larger than 4GB) but you may try this method and see if it works.
Topic archived. No new replies allowed.