From owner-freebsd-hackers Wed Aug 1 18:34:51 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from zogbe.tasam.com (cj45658-a.reston1.va.home.com [65.9.36.73]) by hub.freebsd.org (Postfix) with ESMTP id 7D64937B401 for ; Wed, 1 Aug 2001 18:34:48 -0700 (PDT) (envelope-from clash@tasam.com) Received: from battleship (zogbe.tasam.com [10.45.45.5] (may be forged)) by zogbe.tasam.com (8.11.4/8.11.4) with SMTP id f721YjK52828 for ; Wed, 1 Aug 2001 21:34:46 -0400 (EDT) Message-ID: <00b201c11af3$4fef1c10$0a2d2d0a@battleship> From: "Joseph Gleason" To: Subject: Finding filesizes in C++ for files greater than 4gb Date: Wed, 1 Aug 2001 21:34:43 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.3018.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.3018.1300 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 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) I could use st_blocks, but that wouldn't give me the exact size. (st_blocks -1) * 512 + (st_size % 512) This would make sense, but in tests st_blocks is larger than I would expect. I assume it means that st_blocks is how many blocks the file takes up on the filesystem, and does not directly translate to how large the file is. Backgound: I have some C++ utilities for manipulating files. I have recently (and not supprisingly) discovered that my program has issues with file sizes greater than 4gb because I use an unsigned int for something. I guess I will have to switch to unsigned long long, which appears to be a 64bit int. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message