Method: Chef::Util::FileEdit#write_file
- Defined in:
- lib/chef/util/file_edit.rb
#write_file ⇒ Object
Make a copy of old_file and write new file out (only if file changed)
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/chef/util/file_edit.rb', line 85 def write_file if @changes backup_pathname = original_pathname + ".old" TargetIO::FileUtils.cp(original_pathname, backup_pathname, preserve: true) TargetIO::File.open(original_pathname, "w") do |newfile| editor.lines.each do |line| newfile.puts(line) end newfile.flush end @file_edited = true end @changes = false end |