Skip to content

Instantly share code, notes, and snippets.

@bhelx bhelx/deep_write.rb
Created Oct 8, 2011

Embed
What would you like to do?
write a file in a directory that may not exist
require 'fileutils'
def deep_write(f, data)
FileUtils.mkdir_p(File.dirname(f)) unless File.directory?(File.dirname(f))
File.open(f, 'w').write(data)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.