Ced Ced - 1 month ago 10
Ruby Question

Ruby deleting directories

I'm trying to delete a non-empty directory in Ruby and no matter which way I go about it it refuses to work.
I have tried using FileUtils, system calls, recursively going into the given directory and deleting everything, but always seem to end up with (temporary?) files such as


.__afsECFC

.__afs73B9


Anyone know why this is happening and how I can go around it?

Ced Ced
Answer

Realised my error, some of the files hadn't been closed. I earlier in my program I was using

File.open(filename).read

which I swapped for a

f = File.open(filename, "r")
while line = f.gets
    puts line
end
f.close

And now

FileUtils.rm_rf(dirname)

works flawlessly

Comments