[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: File.size? incorrect for big files?

Nation, Carey

3/14/2008 4:08:00 PM

That did it! Thanks!

-----Original Message-----
From: Daniel Berger [mailto:djberg96@gmail.com]=20
Sent: Thursday, March 13, 2008 3:35 PM
To: ruby-talk ML
Subject: Re: File.size? incorrect for big files?



On Mar 13, 12:59=A0pm, "Nation, Carey" <Carey.Nat...@turner.com> wrote:
> Hi,
>
> I've written a script to monitor some files stored on our network. =
=A0The
> files range from a few hundred MB to 20-50g. =A0Above a certain point
> which I haven't really narrowed down yet, the file sizes start being
> reported incorrectly from my script. =A0It's as if the routine that =
does
> the system query is using a 32 bit thing for the size and it's getting
> truncated as integers do. Some files actually come back with a =
negative
> size. =A0The data type that ruby is using is perfectly capable of =
holding
> the size of the files. =A0I've tried File.size? and FileUtils.size?, =
so
> I'm somewhat at a loss short of writing an extension. Any ideas?
>
> The script is running on windows, querying the files via UNC paths
> through a samba share on linux.

It's a bug in Ruby.

The win32-file library fixes it.

require 'win32/file' # Do this first
File.size(some_big_file)

Regards,

Dan