X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=metadata.cc;fp=metadata.cc;h=dac3d20b1aba6d61866d699005516a016f94e446;hb=fbb042e3bbfe0796b0986fa0ffa9cde75c6e3bce;hp=86d02aa69c7bdd75d1b8995d1d2c4af77b5ead0b;hpb=03e760560aa77aa4f29de0610f41b547ac43ed00;p=cumulus.git diff --git a/metadata.cc b/metadata.cc index 86d02aa..dac3d20 100644 --- a/metadata.cc +++ b/metadata.cc @@ -9,6 +9,7 @@ #include #include +#include #include "metadata.h" #include "ref.h" @@ -16,6 +17,7 @@ #include "util.h" using std::list; +using std::map; using std::string; using std::ostream; using std::ostringstream; @@ -63,6 +65,27 @@ static int pathcmp(const char *path1, const char *path2) return pathcmp(slash1 + 1, slash2 + 1); } +/* Encode a dictionary of string key/value pairs into a sequence of lines of + * the form "key: value". If it exists, the key "name" is treated specially + * and will be listed first. */ +static string encode_dict(const map& dict) +{ + string result; + + if (dict.find("name") != dict.end()) { + result += "name: " + dict.at("name") + "\n"; + } + + for (map::const_iterator i = dict.begin(); + i != dict.end(); ++i) { + if (i->first == "name") + continue; + result += i->first + ": " + i->second + "\n"; + } + + return result; +} + MetadataWriter::MetadataWriter(TarSegmentStore *store, const char *path, const char *snapshot_name,