On Tue, 6 Sep 2005, William James wrote:

> This solution fails under windoze by always returning 0, apparently because
> File.stat(path).ino always returns 0.
>
> If you're stuck with windoze, use the previously posted
>
> def Dir.size(name)
>  Dir[File.join(name, "**/*")].select{|f|
> File.file?(f)}.inject(0){|sum,f|
>    sum + File.size(f)
>  }
> end

works for me :

   Ara@JEN ~
   $ cat a.rb
     require 'alib'

     def dir_size dir
       size = 0
       totalled = {}
       ALib::Util::find2(dir, 'follow' => true) do |path, stat|
         begin
           next if totalled[stat.ino]
           next unless stat.file?
           size += stat.size
         ensure
           totalled[stat.ino] = true
         end
       end
       size
     end

     p dir_size('.')

   Ara@JEN ~
   $ ruby a.rb
   29432845

   Ara@JEN ~
   $ du -sb .
   29432903        .

   Ara@JEN ~
   $ ruby -r rbconfig -r yaml -e'y Config::CONFIG' |egrep -i win
   target: i686-pc-cygwin
   ac_ct_WINDRES: windres
   WINDRES: windres
   archdir: /usr/lib/ruby/1.8/i386-cygwin
   sitearch: i386-cygwin
   arch: i386-cygwin
   host_os: cygwin
   build: i686-pc-cygwin
   host: i686-pc-cygwin
   build_os: cygwin
   target_os: cygwin
   sitearchdir: /usr/lib/ruby/site_ruby/1.8/i386-cygwin

so it seems like your ruby may be broken - how'd you install it?

cheers.

-a
-- 
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze.  --Nagarjuna
===============================================================================