def write(snapshot=:last)
raw_path = self.raw_path(:snapshot => snapshot)
return if raw_path.nil?
FileUtils.mkdir_p(File.dirname(raw_path))
is_created = !File.file?(raw_path)
Nanoc::NotificationCenter.post(:will_write_rep, self, snapshot)
if self.binary?
temp_path = temporary_filenames[:last]
else
temp_path = self.temp_filename
File.open(temp_path, 'w') { |io| io.write(@content[:last]) }
end
is_modified = is_created || !FileUtils.identical?(raw_path, temp_path)
FileUtils.cp(temp_path, raw_path) if is_modified
Nanoc::NotificationCenter.post(:rep_written, self, raw_path, is_created, is_modified)
end