X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=scandir.cc;h=d0ed67d5167bc59e620d8442acc101afa64f11a5;hb=4a6945983fa171fa843c6f8955ba601f733f3ca5;hp=98285aca0b700fbd0831261a2545fc7d2d66dec4;hpb=08721c894385b530ed501498a02d824b8eba7228;p=cumulus.git diff --git a/scandir.cc b/scandir.cc index 98285ac..d0ed67d 100644 --- a/scandir.cc +++ b/scandir.cc @@ -201,19 +201,12 @@ void scandir(const string& path) int main(int argc, char *argv[]) { - struct uuid id = SegmentWriter::generate_uuid(); - string filename = SegmentWriter::format_uuid(id); - - printf("Backup UUID: %s\n", filename.c_str()); - FILE *dump = fopen(filename.c_str(), "w"); - if (dump == NULL) { - fprintf(stderr, "Cannot open file %s: %m\n", filename.c_str()); - return 1; - } + SegmentStore ss("."); + SegmentWriter *sw = ss.new_segment(); + info_dump = sw->new_object(); - FileOutputStream os(dump); - SegmentWriter sw(os, id); - info_dump = sw.new_object(); + string uuid = SegmentWriter::format_uuid(sw->get_uuid()); + printf("Backup UUID: %s\n", uuid.c_str()); try { scanfile("."); @@ -221,5 +214,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "IOException: %s\n", e.getError().c_str()); } + delete sw; + return 0; }