Ara.T.Howard wrote:
> 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?

Mine:

build: i686-pc-mswin32
build_os: mswin32
host: i686-pc-mswin32
host_os: mswin32
target: i386-pc-mswin32
target_os: mswin32

Yours:

build: i686-pc-cygwin
build_os: cygwin
host: i686-pc-cygwin
host_os: cygwin
target: i686-pc-cygwin
target_os: cygwin

Try it without cygwin.  On my system, stat.ino is always 0.

If anyone else is running plain windoze without cygwin, see if
File.stat(path).ino is always 0.