Method: Chef::Util::FileEdit#write_file
- Defined in:
- lib/chef/util/file_edit.rb
permalink #write_file ⇒ Object
Make a copy of old_file and write new file out (only if file changed)
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/chef/util/file_edit.rb', line 76 def write_file # file_edited is false when there was no match in the whole file and thus no contents have changed. if file_edited backup_pathname = original_pathname + ".old" FileUtils.cp(original_pathname, backup_pathname, :preserve => true) File.open(original_pathname, "w") do |newfile| contents.each do |line| newfile.puts(line) end newfile.flush end end self.file_edited = false end |