- out.write(signature2, strlen(signature2));
- out.write_s64(index_offset);
- out.write_u32(objects.size());
+ out->write(signature2, strlen(signature2));
+ out->write_s64(index_offset);
+ out->write_u32(objects.size());
+
+ /* Finally, append a checksum to the end of the file, so that its integrity
+ * (against accidental, not malicious, corruption) can be verified. */
+ const uint8_t *csum = out->finish_and_checksum();
+ raw_out->write(csum, out->checksum_size());
+
+ /* The SegmentWriter takes ownership of the OutputStream it is writing to,
+ * and destroys it automatically when done with the segment. */
+ delete out;
+ delete raw_out;