3

I'm trying to store offsets of a file pointing to different positions on it. Using tellp() function, I can know the actual position in the file, that is, an integer.

The problem comes when this number reaches 4.294.967.295. Overflow appears and then tellp is not showing me a correct number. So, What is the manner of dealing with big (>4GB) files?

auroras
  • 51
  • 3
  • 1
    Looking through the GCC C++ library, the positions will be a 64 bit integer if those are supported by the compiler. – Some programmer dude Oct 01 '12 at 10:23
  • In my case (Intel C++ Compiler) the limit is an ULONG_MAX, that is the same than UINT_MAX, so only 4GB files here. Any tricks? – auroras Oct 01 '12 at 10:29
  • 1
    Remember that `tellp` doesn't actually return a normal integer, it returns a value of type `pos_type`. And that type is probably a specialization of a `std::fpos` class. Search your library for the `std::fpos` class to really know what type the returned position is. – Some programmer dude Oct 01 '12 at 10:38
  • numeric_limits::max() returns me 9223372036854775807, but when the limit of 4GB is reached, (unsigned long long)(os.tellp())... "pos" becomes a small number again – auroras Oct 01 '12 at 11:07

0 Answers0