From: Ed Sinjiashvili Date: 2001-09-27T19:46:33+09:00 Subject: [ruby-talk:21765] Re: Problem with directory? Re: Path walking on windows Charles Hixson writes: > > Dir.new(tip_root).walk {|p| puts p } > # if p =~ /\.([Hh][Tt][Mm]([Ll])?)$/ } > > This code simply lists all files in the directory. Even the included > directories are shown as "is not a directory". And no descent into > the sub-directories is attempted (naturally). I'm sorry to answer so late but I was away for a while. The problem with this code is that you don't give prefix dir to initial #walk invocation. Dir class has a notion of working directory - you can retrieve it with #pwd. #walk method never changes that class variable, i.e. it does not #chdir into directories. Instead it receives prefix parameter which is a relative path to current working directory. I used to start from current dir - so I didn't pass "." to walk. Following two calls are effectively equivalent: Dir.new(".").walk "." {|p| puts p} Dir.new(".").walk {|p| puts p} But if you don't start walking from current dir - you should always pass relative prefix to #walk. It's a tradeoff of not changing working directory. Dir.new(tip_root).walk(tip_root) {|p| puts p } I hope this helps and I suggest you to try mswin32 port of ruby. As I said in some previous post - it's way faster than cygwin . -- Ed Sinjiashvili