win32 file stat and find conflict

L

lrlebron

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
 
D

Daniel Berger

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top