From: "Paul E.C. Melis" Date: 2002-06-26T19:33:55+09:00 Subject: Re: rm -rf It is kind of weird that there is a Dir.delete method that throws an exception when the dir isn't empty, but that there isn't a Dir method that allows you to delete one that isn't. Isn't that overly cautious? Paul wrote in message news:200206251559.g5PFxmp05227@sharui.nakada.kanuma.tochigi.jp... > Hi, > > At Tue, 25 Jun 2002 23:34:40 +0900, > Bil Kleb wrote: > > > I'm curious, rm -rf will just as well work for a GNU/Linux box, so I guess > > > you don't simply want to execute this as a shell command from your Ruby > > > script with `rm -rf `? > > > > Right, for some reason I'm against using system or back ticks today. > > dirs = [] > Dir.glob("#{path}/**/{.[^.],..?,}*") do |f| > if File.directory?(f) > dirs << f > else > File.unlink(f) > end > end > dirs.reverse_each(&Dir.method(:rmdir)) > > -- > Nobu Nakada >