Date: Wed, 1 Aug 2001 21:34:43 -0400 From: "Joseph Gleason" <clash@tasam.com> To: <freebsd-hackers@FreeBSD.ORG> Subject: Finding filesizes in C++ for files greater than 4gb Message-ID: <00b201c11af3$4fef1c10$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-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00b201c11af3$4fef1c10$0a2d2d0a>