From: Daniel Berger Date: 2006-12-03T23:12:54+09:00 Subject: Re: File.size() returning negative for large files ???? Pedro Fortuny Ayuso wrote: > On 12/3/06, Eric Hodel wrote: >> >> On Dec 3, 2006, at 24:30 , Greg Hauptmann wrote: >> > On 12/3/06, Damjan Rems wrote: >> >> Greg Hauptmann wrote: >> >>> I'm getting a negative number being returned for large files when >> >>> using File.size()??? Any ideas? One of my ruby books says an >> >>> Integer can be any size?? >> >>> >> >>> I'm using: >> >>> - File.size(path) >> >>> - getting negative number responses for large files (e.g. >> >>> -1001581 where file was really around 3.2GB) >> >> >> >> It is not yours, but Windows fault. >> > >> > Is there a work around for this guys? >> >> [-1001581].pack('l').unpack('L').first # => 4293965715 > > > However, notice that for VERY large files, (larger than 4Gb, I guess, > or 4294967296 bytes), that method fails also > > [4294967296].pack('l') > > is the same as > > [4294967296*2].pack('l') > > So something different ought to be used. You might as well get > the info from "system (dir)" or similar for your specific case. > > Pedro > > > Try 'Q' instead. Or, just use win32-file. :) Regards, Dan