On 02-Aug-2001 Joseph Gleason wrote:
>  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.

st_size is an off_t which is typedef'd to _BSD_OFF_T_ which is #define'd as
__int64_t.

So.. you're program should grok >4Gb files.

>  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.

I would explicitly use off_t for file offsets/sizes which is what it is
designed for.

If you want an explicit bit width use it, eg u_int64_t etc.

That way you get what you ask for rather than second guessing the implementor.
 
---
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to