# Win32 file stat and find conflict

**URL:** <https://www.ruby-forum.com/t/win32-file-stat-and-find-conflict/80029>\
**Category:** Ruby\
**Created:** [December 20, 2006, 10:32pm UTC](https://www.ruby-forum.com/t/win32-file-stat-and-find-conflict/80029 "2006-12-20T22:32:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 20, 2006, 10:32pm UTC](https://www.ruby-forum.com/t/win32-file-stat-and-find-conflict/80029/1 "2006-12-20T22:32:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 21, 2006, 2:55am UTC](https://www.ruby-forum.com/t/win32-file-stat-and-find-conflict/80029/2 "2006-12-21T02:55:10Z")

</div>

removed\_email\_address@domain.invalid wrote:

> 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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 21, 2006, 2:57am UTC](https://www.ruby-forum.com/t/win32-file-stat-and-find-conflict/80029/3 "2006-12-21T02:57:11Z")

</div>

From: removed\_email\_address@domain.invalid [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]:

# 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?

cannot help you, but, i can also second that behavior here.  
wish there was something like “unrequire” the "require"d

maybe something like,

require ‘win32/file/stat’  
begin  
test\_require ‘win32/file/stat’  
rescue  
require ‘win32/file/stat’ :uninstall =\> true  
end

🙂

kind regards -botp

# thanks,

# Luis
