atomic_write: create path before writing file

This commit is contained in:
Jörg Thalheim 2015-01-15 09:06:01 +01:00
parent bdcc3e2be5
commit a03bb44e10
1 changed files with 4 additions and 0 deletions

View File

@ -19,6 +19,10 @@ class Registry
end
def atomic_write(path, content)
dir = File.dirname(path)
unless Dir.exist?(dir)
FileUtils.mkdir_p(dir)
end
temp_path = path.to_s + ".tmp"
File.open(temp_path, 'w+') do |f|
f.write(content)