The map::at method does not always exist, so instead use map::find.
[cumulus.git] / metadata.cc
index f29c486..2ae0751 100644 (file)
@@ -24,6 +24,8 @@
  * handling of the statcache, and re-use of metadata between snapshots.
  */
 
+#include <stdlib.h>
+#include <string.h>
 #include <string>
 #include <iostream>
 #include <map>
@@ -96,7 +98,7 @@ static string encode_dict(const map<string, string>& dict)
     string result;
 
     if (dict.find("name") != dict.end()) {
-        result += "name: " + dict.at("name") + "\n";
+        result += "name: " + dict.find("name")->second + "\n";
     }
 
     for (map<string, string>::const_iterator i = dict.begin();
@@ -116,7 +118,7 @@ MetadataWriter::MetadataWriter(TarSegmentStore *store,
 {
     statcache_path = path;
     statcache_path += "/statcache2";
-    if (snapshot_scheme != NULL)
+    if (snapshot_scheme != NULL && strlen(snapshot_scheme) > 0)
         statcache_path = statcache_path + "-" + snapshot_scheme;
     statcache_tmp_path = statcache_path + "." + snapshot_name;
 
@@ -126,7 +128,7 @@ MetadataWriter::MetadataWriter(TarSegmentStore *store,
     if (statcache_out == NULL) {
         fprintf(stderr, "Error opening statcache %s: %m\n",
                 statcache_tmp_path.c_str());
-        throw IOException("Error opening statcache");
+        fatal("Error opening statcache");
     }
 
     old_metadata_eof = false;