Created
June 27, 2011 16:05
-
-
Save pcarrier/1049160 to your computer and use it in GitHub Desktop.
recursive_mkdir.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.mkdir_p(path) | |
path_acc = '' | |
path = File.join Dir.pwd, path if path[0] != ?/ | |
path.split(File::SEPARATOR).grep(/./).collect do |name| | |
path_acc += File::SEPARATOR+ name | |
end.each do |dir| | |
begin Dir.mkdir(dir) rescue Errno::EEXIST end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah ah in Ruby too.
Well that was fun to write anyway.
require 'ftools'
File.makedirs ("/path/that/exists/or/not")