def self.write_tempfile data_to_write
file = Tempfile.open(['eyaml_edit', '.yaml'])
path = file.path
file.close!
file = File.open(path, "w")
file.chmod(0600)
if ENV['OS'] == 'Windows_NT'
icacls = 'C:\Windows\system32\icacls.exe'
if File.executable? icacls
current_user = `C:\\Windows\\system32\\whoami.exe`.chomp
command = %Q{#{icacls} "#{file.path}" /grant:r "#{current_user}":f /inheritance:r}
system "#{command} >NUL 2>&1"
end
end
file.puts data_to_write
file.close
LoggingHelper::debug "Wrote temporary file: #{path}"
path
end