+
+SegmentStore::SegmentStore(const string &path)
+ : directory(path)
+{
+}
+
+SegmentWriter *SegmentStore::new_segment()
+{
+ struct uuid id = SegmentWriter::generate_uuid();
+ string filename = directory + "/" + SegmentWriter::format_uuid(id);
+
+ FILE *f = fopen(filename.c_str(), "wb");
+ if (f == NULL)
+ throw IOException("Unable to open new segment");
+
+ return new SegmentWriter(new FileOutputStream(f), id);
+}