From a03bb44e10aa6de84d0afca306d88b2ddf81b842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 15 Jan 2015 09:06:01 +0100 Subject: [PATCH] atomic_write: create path before writing file --- scripts/utils.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/utils.rb b/scripts/utils.rb index 9429bf5..58c4d94 100644 --- a/scripts/utils.rb +++ b/scripts/utils.rb @@ -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)