[LC++]standard way to seek big files

Kai Vehmanen k at eca.cx
Thu Dec 6 17:09:04 UTC 2001


I've just added support for handling big (>2GB) files on 32bit platforms 
to a Linux C++ app. Looking at the standards, if using <cstdio>, there 
seems to be no standard way of either setting or getting numerical 
position of these big, "64bit" files.

std::fseek() and std::ftell() are part of the standard, but take a 'long
int' as their offset argument. std::fsetpos() and std::fgetpos() can be
used with a 64bit fpos_t, but as 'fpos_t' is an opaque type, it's not a
full replacement for fseek/ftell.

Single Unix specification has fseeko/ftello and these are what I'm using 
now. But of course, they are not part of the C/C++ standard, so not an 
optimal solution.

Any experiences with this? How's the situation when using streams, any 
problems handling large files? 

PS Platforms where 'size(long int) > 4' this is of course not 
   a problem.

-- 
 http://www.eca.cx
 Audio software for Linux!




More information about the tuxCPProgramming mailing list