From: Charles Hixson Date: 2001-09-25T02:11:00+09:00 Subject: [ruby-talk:21640] Re: Problem with directory? Re: Path walk ing on windows That runs, but without detecting the directories as separate from files. A kind-of solution that I have found is to use: print "show tip files:\n" val = "#{tip_root}/*.html" print "file pattern: <<#{val}\n" print `find "#{tip_root}" -name "*.html" -print` print "\n" to create the list of files, which can then be picked apart for processing. But this doesn't really solve anything. I can drop into shell commands whenever I want to check I guess, though I'm not sure... how complete is zsh? This may only be a feasible answer when I'm running under cygwin. I seem to recall that on Friday when I tried to use `ls ...` in the same way that I used find today, it didn't work the way that I expected it to. But that time I was running from WinRuby, so perhaps the shell environment was different than when I am running under CygWin. (I do remember that I was shocked when `dir ...` returned the information that dir wasn't a recognized command.) SHULTZ,BARRY (HP-Israel,ex1) wrote: > Hi Charles, > > It works for me if I change > > if test("d?", x) > > to > > if FileTest.directory?(x) > > HTH, > Barry > > >>-----Original Message----- >>From: Charles Hixson [mailto:charlesh@pop.newsguy.com] >>Sent: Sunday, September 23, 2001 5:43 AM >>To: ruby-talk@ruby-lang.org >>Subject: [ruby-talk:21578] Re: Problem with directory? Re: >>Path walking >>on windows >> >> >>class Dir >> def walk (prefix = nil, &walker) >> e = self.entries >> e.delete "."; e.delete ".." >> if prefix >> e.collect! {|x| File.join(prefix, x) } >> end >> >> if block_given? >> e.each {|x| >> print "Processing <<#{x}>> " >># afile = File.lstat(x) >># puts afile.inspect >># f = File.ftype(afile) >># puts f.inspect >># if f.directory? then >># if f == "directory" then >> if test("d?", x) >> Dir.new(x).walk x, &walker >> else >> puts "#{x} is not a directory." >> end >> yield x >> } >> end >> >> nil >> end >>end >> >> > >