# File lib/nanoc/base/result_data/item_rep.rb, line 122
      def write(snapshot=:last)
        # Get raw path
        raw_path = self.raw_path(:snapshot => snapshot)
        return if raw_path.nil?

        # Create parent directory
        FileUtils.mkdir_p(File.dirname(raw_path))

        # Check if file will be created
        is_created = !File.file?(raw_path)

        # Calculate characteristics of old content
        if File.file?(raw_path)
          hash_old = Pathname.new(raw_path).checksum
          size_old = File.size(raw_path)
        end

        # Notify
        Nanoc::NotificationCenter.post(:will_write_rep, self, snapshot)

        if self.binary?
          # Calculate characteristics of new content
          size_new = File.size(temporary_filenames[:last])
          hash_new = Pathname.new(temporary_filenames[:last]).checksum if size_old == size_new

          # Check whether content was modified
          is_modified = (size_old != size_new || hash_old != hash_new)

          # Copy
          if is_modified
            FileUtils.cp(temporary_filenames[:last], raw_path)
          end
        else
          # Check whether content was modified
          is_modified = (!File.file?(raw_path) || File.read(raw_path) != @content[:last])

          # Write
          if is_modified
            File.open(raw_path, 'w') { |io| io.write(@content[:last]) }
          end
        end

        # Notify
        Nanoc::NotificationCenter.post(:rep_written, self, raw_path, is_created, is_modified)
      end