diff c/utils.cpp @ 1014:026f6b3b122c

Moving pull request2
author Wendlasida
date Fri, 01 Jun 2018 17:32:52 -0400
parents 6c5ce3ec497e
children
line wrap: on
line diff
--- a/c/utils.cpp	Fri Jun 01 17:29:01 2018 -0400
+++ b/c/utils.cpp	Fri Jun 01 17:32:52 2018 -0400
@@ -1,10 +1,13 @@
 #include "utils.hpp"
 
 #include <boost/foreach.hpp>
+#include <boost/filesystem.hpp>
 
 #include <iostream>
 #include <fstream>
 
+namespace fs = boost::filesystem; // soon std
+
 using namespace std;
 
 std::vector<std::vector<float> > loadNumbers(const string& filename, const string& separator /* = " " */) {
@@ -27,6 +30,15 @@
   return result;
 }
 
+std::string getRelativeFilename(const std::string& parentDirname, const std::string& filename) {
+  fs::path parentPath(parentDirname);
+  fs::path filePath(filename);
+  if (filePath.is_absolute())
+    return filename;
+  else
+    return (parentPath/filePath).string();
+}
+
 int toInt(const std::string& s) { int i; fromString(i, s); return i;} //atoi
 
 float toFloat(const std::string& s) { float x; fromString(x, s); return x;}// lexical_cast<float>(s)