Skip to content

Instantly share code, notes, and snippets.

@pcarrier
Created June 27, 2011 16:05
Show Gist options
  • Save pcarrier/1049160 to your computer and use it in GitHub Desktop.
Save pcarrier/1049160 to your computer and use it in GitHub Desktop.
recursive_mkdir.rb
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
@Daenyth
Copy link

Daenyth commented Jun 28, 2011

Indeed. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment