From: "SHULTZ,BARRY (HP-Israel,ex1)" Date: 2001-09-26T20:59:31+09:00 Subject: [ruby-talk:21717] Re: Problem with directory? Re: Path walkin g on windows I'm running the same Ruby, under Win95 4.00.950r-7 and I'm not getting any "false negatives" using FileTest.directory? . Can you characterize the problem directories in some way? Barry > > It runs without detecting an error, but it misidentifies actual > directories as normal files. > (Again, this is on a Win95 4.00.950 B system.) > $ ruby -v > ruby 1.6.3 (2001-03-19) [i386-cygwin] > > (Though it doesn't matter whether I run ruby under dos or > cygwin, or even directly from RubyWin .. the exact same result > obtains.) > > > Date: Sun, 23 Sep 2001 15:31:02 +0900 > > From: "SHULTZ,BARRY (HP-Israel,ex1)" > > To: ruby-talk@ruby-lang.org (ruby-talk ML) > > > > > > 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 > > > > > > > -- > Charles Hixson > > Copy software legally, the GNU way! > Use GNU software, and legally make and share copies of software. > See http://www.gnu.org > http://www.redhat.com > http://www.linux-mandrake.com > http://www.calderasystems.com/ > http://www.linuxapps.com/ >