On 02-Aug-01 Joseph Gleason wrote:
> In FreeBSD, how can I determine the size of a file in C++ when the file is
> greater than 4gb?
>
> Currently, I use stat() and use st_size. That is limited to 4gb (32bit
> unsigned int)
struct stat {
...
off_t st_size; /* file size, in bytes */
...
}
/usr/include/sys/types.h:typedef _BSD_OFF_T_ off_t; /* file
offset */
/usr/include/machine/ansi.h:#define _BSD_OFF_T_ __int64_t /* file
offset */
st_size is not 32 bits on any arch's FreeBSD runs on. However, you need to
include <sys/types.h> and use off_t for file offsets rather than int or long,
which should fix your problem.
--
John Baldwin <[EMAIL PROTECTED]> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!" - http://www.FreeBSD.org/
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message