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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to