I can't get FileUtils to delete a directory

Hi there,
I created a test folder with two sub-folders inside and now I want to
delete the main folder.
In irb I typed:
require 'fileutils'
FileUtils.rm_f("test")

I'm running the command from C: and the folder is directly off C:
I assumed it should just delete but nothing's happening...
I know Dir.delete won't delete a folder if there is something in it. I
want to figure out how to delete the folder in one command rather than
having to go through it deleting all the sub folders one by one. I'm
sure there's a way to do this?

···

--
Posted via http://www.ruby-forum.com/.

This is similar to the command line version on unix systems, where
removing a directory recursively require the -r option. The same
applies here. Use rm_rf instead of rm_f.

  FileUtils.rm_rf('test')

Regards,
Ammar

···

On Wed, Dec 1, 2010 at 12:59 PM, Tara Keane <tararakeane@hotmail.com> wrote:

Hi there,
I created a test folder with two sub-folders inside and now I want to
delete the main folder.
In irb I typed:
require 'fileutils'
FileUtils.rm_f("test")

Great that worked thanks a lot...

···

--
Posted via http://www.ruby-forum.com/.

I don't get it...

(newbie - sorry)
But I do know one

A SQL query walks up to a table in a bar and says 'mind if I join you?'

···

--
Posted via http://www.ruby-forum.com/.

hahaha :wink:

···

--
Posted via http://www.ruby-forum.com/.

Great! Now where's my /usr/bin? Just kidding. :wink:

Cheers

robert

···

On Wed, Dec 1, 2010 at 1:19 PM, Tara Keane <tararakeane@hotmail.com> wrote:

Great that worked thanks a lot...

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

rm -rf has a history of being accidentally used to clobber very
important data from a Unix system. If you're running as the root user
on Unix, you have the ability to wipe out the entire filesystem,
including the operating system's files, rather than just your personal
home directory and any other limited directories to which you have write
access. Under older systems, you needed to have the password for the
root user in order to operate in its name. Thus, to really f**k things
up, you need root's password. :slight_smile:

The moral of the story is to use rm -rf and any similar facility such as
FileUtils.rm_rf with extreme caution.

-Jeremy

···

On 12/1/2010 8:39 AM, Tara Keane wrote:

I don't get it...

(newbie - sorry)

That's an educational joke. Reminds me of: "to err is human, to really
f**k things up requires the root password."

Cheers,
Ammar

···

On Wed, Dec 1, 2010 at 4:17 PM, Robert Klemme <shortcutter@googlemail.com> wrote:

On Wed, Dec 1, 2010 at 1:19 PM, Tara Keane <tararakeane@hotmail.com> wrote:

Great that worked thanks a lot...

Great! Now where's my /usr/bin? Just kidding. :wink: