* is built on top of libtar, and represents segments as TAR files and objects
* as files within them. */
+#include <assert.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
-#include <uuid/uuid.h>
#include <list>
#include <set>
#include <iostream>
#include "store.h"
+#include "ref.h"
using std::list;
using std::set;
if (segments.find(group) == segments.end()) {
segment = new segment_info;
- uint8_t uuid[16];
- char uuid_buf[40];
- uuid_generate(uuid);
- uuid_unparse_lower(uuid, uuid_buf);
- segment->name = uuid_buf;
+ segment->name = generate_uuid();
string filename = path + "/" + segment->name + ".tar";
segment->file = new Tarfile(filename, segment->name);
{
return object;
}
+
+LbsObject::LbsObject()
+ : group(""), data(NULL), data_len(0), written(false)
+{
+}
+
+LbsObject::~LbsObject()
+{
+}
+
+void LbsObject::add_reference(const LbsObject *o)
+{
+ refs.insert(o->get_name());
+}
+
+void LbsObject::write(TarSegmentStore *store)
+{
+ assert(data != NULL);
+ assert(!written);
+
+ list<string> reflist;
+ for (set<string>::iterator i = refs.begin(); i != refs.end(); ++i) {
+ reflist.push_back(*i);
+ }
+
+ name = store->write_object(data, data_len, group, reflist);
+
+ written = true;
+ data = NULL;
+}