Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 01 Aug 2001 18:42:32 -0700 (PDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Joseph Gleason <clash@tasam.com>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   RE: Finding filesizes in C++ for files greater than 4gb
Message-ID:  <XFMail.010801184231.jhb@FreeBSD.org>
In-Reply-To: <00b201c11af3$4fef1c10$0a2d2d0a@battleship>

next in thread | previous in thread | raw e-mail | index | archive | help

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 <jhb@FreeBSD.org> -- 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 majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.010801184231.jhb>