From: Pedro Fortuny Ayuso Date: 2006-12-03T20:13:48+09:00 Subject: Re: File.size() returning negative for large files ???? ------=_Part_25955_30568692.1165144425130 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 -- Pedro Fortuny Ayuso C/Capuchinos 14, 1. 47006 Valladolid. SPAIN http://pfortuny.sdf-eu.org ------=_Part_25955_30568692.1165144425130--