Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Aug 2001 20:57:36 -0400
From:      "Joseph Gleason" <clash@tasam.com>
To:        "FBSD-Q" <freebsd-questions@FreeBSD.ORG>
Subject:   filesizes greater than 4gb
Message-ID:  <002b01c11aee$21b9ae00$0a2d2d0a@battleship>

next in thread | raw e-mail | index | archive | help
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-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?002b01c11aee$21b9ae00$0a2d2d0a>