From owner-freebsd-hackers Wed Aug 1 18:42:34 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mail5.speakeasy.net (mail5.speakeasy.net [216.254.0.205]) by hub.freebsd.org (Postfix) with SMTP id 4EFBA37B401 for ; Wed, 1 Aug 2001 18:42:32 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 66840 invoked from network); 2 Aug 2001 01:42:31 -0000 Received: from unknown (HELO laptop.baldwin.cx) ([64.81.54.73]) (envelope-sender ) by mail5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 2 Aug 2001 01:42:31 -0000 Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <00b201c11af3$4fef1c10$0a2d2d0a@battleship> Date: Wed, 01 Aug 2001 18:42:32 -0700 (PDT) From: John Baldwin To: Joseph Gleason Subject: RE: Finding filesizes in C++ for files greater than 4gb Cc: freebsd-hackers@FreeBSD.ORG Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 and use off_t for file offsets rather than int or long, which should fix your problem. -- John Baldwin -- 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