|
Versions Of This Snippet::
Download a raw-text version of this code by clicking on "Download Version"
Latest Snippet Version: :0.1
def recursive_delete(dir)
files = []
Dir.foreach(dir) do |fname|
next if fname == '.' || fname == '..'
path = dir + '/' + fname
if File.directory?(path)
puts "dir #{path}"
recursive_delete(path)
else
puts "file #{path}"
files << path
end
end
files.each do |path|
puts "delete file #{path}"
#File.delete(path)
end
puts "delete dir #{dir}"
Dir.rmdir(dir)
end
Submit a new versionYou can submit a new version of this snippet if you have modified it and you feel it is appropriate to share with others..
|
||||||||||||||||||||||||||
