On Mar 24, 2004, at 12:48 PM, walter / mwsewall.com wrote:

> File.stat('file_name').size returns erroneous file sizes when the
> files are over 2 Gigs in size (at which point the number wraps around
> and becomes negative).  Is this an expected limitation or a bug?
>
> I am using the Pragmatic Programmers 1.8.1-11 build on a windows 2000
> machine.

It looks like a bug (that is, it doesn't happen that way on my box). 
I'm guessing that it's a signed <vs> unsigned integer problem. When it 
wraps around, does it start out at negative one and go upward fro 
increasing file sizes?

> Is there a work around?

try:
   [File.stat("filename").size].pack("i").unpack("I")

This packs the number as a signed integer, and unpacks it as an 
unsigned one. If it works, you can make a quick function:

   class Integer
     def unsign() [self].pack("i").unpack("I") end
   end

and...
   File.stat("somefile").size.unsign

--Mark