Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > File.size? incorrect for big files?

Reply
Thread Tools

File.size? incorrect for big files?

 
 
Nation, Carey
Guest
Posts: n/a
 
      03-13-2008
Hi,

I've written a script to monitor some files stored on our network. The
files range from a few hundred MB to 20-50g. Above a certain point
which I haven't really narrowed down yet, the file sizes start being
reported incorrectly from my script. It'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. The data type that ruby is using is perfectly capable of holding
the size of the files. I've tried File.size? and FileUtils.size?, so
I'm somewhat at a loss short of writing an extension. Any ideas?

=20

The script is running on windows, querying the files via UNC paths
through a samba share on linux.

=20

Thanks!

=20

________________________________

Carey Nation <(E-Mail Removed)> =20

Lead Software Engineer

CNN BEST

Broadcast Production Systems

Video Solutions Group

(404)827-2935 (wk)

(404)824-0033 (cell)

________________________________

=20


 
Reply With Quote
 
 
 
 
Fred Talpiot
Guest
Posts: n/a
 
      03-13-2008
Some versions, maybe all, of the windows libraries have a bug in
File.size.
Make sure you have the latest win32 gems, it seems to help.

The 'gem outdated' and 'gem update' commands can help.

The only bug I've seen is on moderately sized files where the ruby code
closes the file then immediately checks the file size. It came back as
zero. I worked around it several versions ago, so my info is not as of
today.


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Daniel Berger
Guest
Posts: n/a
 
      03-13-2008


On Mar 13, 12:59=A0pm, "Nation, Carey" <(E-Mail Removed)> 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

 
Reply With Quote
 
Nobuyoshi Nakada
Guest
Posts: n/a
 
      03-14-2008
Hi,

At Fri, 14 Mar 2008 03:59:30 +0900,
Nation, Carey wrote in [ruby-talk:294466]:
> The script is running on windows, querying the files via UNC paths
> through a samba share on linux.


Microsoft Visual C's runtime doesn't support large files, so
ruby compiled with it also doesn't. Ruby 1.9 replaces some
functions to fix it.

--
Nobu Nakada

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net 0 12-26-2008 09:29 AM
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net Web Controls 0 12-26-2008 06:11 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Python 0 12-24-2008 07:35 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Ruby 0 12-24-2008 05:07 AM
Big JARs = Big Problems? kk_oop@yahoo.com Java 11 09-18-2005 05:54 PM



Advertisments