Re: [AD] al_find file size

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Monday 07 November 2005 04:01 pm, Evert Glebbeek wrote:
> Afraid not, at least not for 4.2. For one thing, doing so will break
> binarycompatibility. For another, long long is not C89. For 4.3 and up,
> possibly, depending on what we want to do with the file functions.
> I'm curious though, how do the operating system API's deal with this issue?
> Have they always returned a 64 bit integer for filesize?

According to my man pages, fseek and ftell both use long. On Linux, there are 
the functions fseeko and ftello which use the off_t type:

The  fseeko()  and  ftello()  functions  are  identical to fseek() and ftell() 
(see fseek(3)), respectively, except that the offset argument of fseeko() and 
the return value of ftello() is of type off_t instead of long.
On many architectures both off_t and long are 32-bit types, but compilation 
with
#define _FILE_OFFSET_BITS 64
will turn off_t into a 64-bit type.

Unfortunately those functions conform to SUSv2, and probably won't work on 
Windows. My copy of XMinGW, however, has the functions fseeko64/ftello64 and 
use the off64_t type.

Probably the best thing to do would be to use (u)int64_t, define 
_FILE_OFFSET_BITS to 64, and just use the compiler-specific fseek/ftell 
function, casting as needed.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/