[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

win32 file stat and find conflict

lrlebron@gmail.com

12/20/2006 9:27:00 PM

I have a small snippet of code to recurse a directory which works as it
should

require 'find'

Find::find('C:\test') do |f|
p f
end

When I change it like this

require 'win32/file/stat'
require 'find'

Find::find('C:\test') do |f|
p f
end

Only the 'C:\test' directory is printed. None of the files or
subdirectories show up.

Any ideas on how to fix this?

thanks,

Luis

1 Answer

Daniel Berger

12/21/2006 1:53:00 AM

0

lrlebron@gmail.com wrote:
> I have a small snippet of code to recurse a directory which works as it
> should
>
> require 'find'
>
> Find::find('C:\test') do |f|
> p f
> end
>
> When I change it like this
>
> require 'win32/file/stat'
> require 'find'
>
> Find::find('C:\test') do |f|
> p f
> end
>
> Only the 'C:\test' directory is printed. None of the files or
> subdirectories show up.
>
> Any ideas on how to fix this?

Don't require 'win32/file/stat' directly. Require win32-file instead,
which will, in turn, require win32-file-stat.

The reason is that the 'find' module is calling File.lstat internally,
which is just a pass through method to File::Stat. For it to work
properly you need to use the File.lstat method that I've defined in the
win32-file package.

I've updated the README file for win32-file-stat to explain the
situation in a little more detail (and added a warning that you should
never require win32-file-stat directly).

Regards,

Dan