From: Kurt Euler Date: 2002-08-15T04:47:24+09:00 Subject: RE: How to use the safe_unlink method? Thanks! -----Original Message----- From: Mauricio Fern�ndez [mailto:batsman.geo@yahoo.com] Sent: Wednesday, August 14, 2002 12:37 PM To: ruby-talk@ruby-lang.org Subject: Re: How to use the safe_unlink method? On Thu, Aug 15, 2002 at 03:01:41AM +0900, Kurt Euler wrote: > Guy- > > Thanks, but a follow-up question: > > How exactly would I rewrite my file (which happens to be named "dl.rb") which currently includes just this text: > > require 'ftools' > File.safe_unlink(".\output\*.*") > > Do you think this code should be correct as written? (I don't > understand your "ruby -rftools -e" text.) He's creating a file named ".output*.*" and deleting it with the line you used. He's showing you 2 errors there: 1) usage of '\' in the string: it's gotta be escaped: "\\" NOTE: maybe Ruby uses '/' as a dir. separator even in Win*, you'll have to test 2) File.safe_unlink doesn't accept file globs. Use something like (untested) require 'ftools' files = Dir[".\\output\\*.*"] files.each { |x| File.safe_unlink x } -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com * JHM wonders what Joey did to earn "I'd just like to say, for the record, that Joey rules." -- Seen on #Debian