|
Boost : |
From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2004-01-31 12:44:02
Beman Dawes wrote:
> On POSIX compliant 32-bit systems, is there any reliable way to find the
> size of a file?
First, POSIX only had stat(), which is limited to 32 bits, as you
found out. When files got large enough that this wasn't a good
assumption any more even on 32bit systems, a new interface was
introduced: stat64() which has, for example, a 64bit
stat64::st_size .
(Btw, Linux 2.6 supports up to 16 TB file sizes on 32bit machines,
AFAIK.)
Of course, 64bit environments have their regular stat()
use 64bit stat::st_size.
You get stat64() by #define _LARGEFILE64_SOURCE .
You get stat() to use a 64bit stat::st_size even on 32bit
environments by #define _FILE_OFFSET_BITS=64 .
Both options require reasonably recent Unix systems.
The latter option may impede binary compatibility if some
modules are compiled with the #define and others aren't,
because the perceived "struct stat" size will be different.
Jens Maurer
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk