16Apr/083
Recursively creating a set of directories in Ruby
class Dir def self.mkdirs(p) return if File.exists? dir, file = File.split(p) Dir.mkdirs(dir) if !File.exists?(dir) Dir.mkdir(p) end end
#sample usage: Dir.mkdirs('test/tmp/tempest')
class Dir def self.mkdirs(p) return if File.exists? dir, file = File.split(p) Dir.mkdirs(dir) if !File.exists?(dir) Dir.mkdir(p) end end
#sample usage: Dir.mkdirs('test/tmp/tempest')
June 13th, 2008 - 04:11
ha ha ha
December 9th, 2008 - 10:14
Or you could use the ruby built-in version of:
Dir.mkdir_p “/dir/that/does/not/exist”
December 9th, 2008 - 11:10
@Ari
There goes my 15 secs of fame to the dumps – showcasing my bad googling skills. Btw, thank you for the tip!
Btw thank you for providing the link to your site. Its a great resource and my weekend read!