From b1a0bfe834d45694851787317da2cd55add2d7bb Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Thu, 10 May 2007 17:43:00 -0700 Subject: [PATCH] Miscellaneous changes. - Disable profiling output for now. It can be turned on again later. - Allow destination directory for backup files to be specified on the command-line (but we should add proper command-line parsing later). - More work to track inter-object references, but not yet finished. --- Makefile | 5 +++-- scandir.cc | 6 +++++- sha1.cc | 2 +- store.cc | 9 +++++++-- store.h | 2 ++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ffa28a3..9f6892b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ PACKAGES=uuid -CXXFLAGS=-O -Wall -D_FILE_OFFSET_BITS=64 -g -pg \ +DEBUG=-g #-pg +CXXFLAGS=-O -Wall -D_FILE_OFFSET_BITS=64 $(DEBUG) \ `pkg-config --cflags $(PACKAGES)` -LDFLAGS=-g -pg -ltar `pkg-config --libs $(PACKAGES)` +LDFLAGS=$(DEBUG) -ltar `pkg-config --libs $(PACKAGES)` SRCS=format.cc scandir.cc sha1.cc store.cc OBJS=$(SRCS:.cc=.o) diff --git a/scandir.cc b/scandir.cc index 223a99c..c11c561 100644 --- a/scandir.cc +++ b/scandir.cc @@ -276,7 +276,11 @@ int main(int argc, char *argv[]) { block_buf = new char[LBS_BLOCK_SIZE]; - tss = new TarSegmentStore("."); + if (argc > 1) { + tss = new TarSegmentStore(argv[1]); + } else { + tss = new TarSegmentStore("."); + } std::ostringstream metadata; diff --git a/sha1.cc b/sha1.cc index 517b224..c7b7112 100644 --- a/sha1.cc +++ b/sha1.cc @@ -358,7 +358,7 @@ string SHA1Checksum::checksum_str() { uint8_t resbuf[20]; char hexbuf[4]; - string result = "sha-1:"; + string result = "sha1="; sha1_finish_ctx(&ctx, resbuf); diff --git a/store.cc b/store.cc index 804992f..49f002a 100644 --- a/store.cc +++ b/store.cc @@ -196,7 +196,7 @@ LbsObject::~LbsObject() void LbsObject::add_reference(const LbsObject *o) { - // TODO: Implement + refs.insert(o->get_name()); } void LbsObject::write(TarSegmentStore *store) @@ -204,7 +204,12 @@ void LbsObject::write(TarSegmentStore *store) assert(data != NULL); assert(!written); - name = store->write_object(data, data_len, group); + list reflist; + for (set::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; diff --git a/store.h b/store.h index 516a20c..6906d63 100644 --- a/store.h +++ b/store.h @@ -145,6 +145,8 @@ private: bool written; std::string name; + + std::set refs; }; #endif // _LBS_TARSTORE_H -- 2.20.1