Merge branch 'master' into windows
[ardour.git] / libs / pbd / pathexpand.cc
index 4911f127881f6aff7f6c5dac6e6e825650009372..5784ec942855de3ece0de4e9809333efbb5278e1 100644 (file)
 */
 
 #include <vector>
-#include <climits>
 #include <iostream>
+#include <climits>
+#include <cerrno>
+#include <cstdlib>
 
 #include <regex.h>
 
 using std::string;
 using std::vector;
 
+string
+PBD::canonical_path (const std::string& path)
+{
+#ifdef COMPILER_MINGW
+       return path;
+#else
+       char buf[PATH_MAX+1];
+
+       if (!realpath (path.c_str(), buf) && (errno != ENOENT)) {
+               return path;
+       }
+
+       return string (buf);
+#endif
+}
+
 string
 PBD::path_expand (string path)
 {
@@ -97,13 +115,7 @@ PBD::path_expand (string path)
 
        /* canonicalize */
 
-       char buf[PATH_MAX+1];
-
-       if (realpath (path.c_str(), buf)) {
-               return buf;
-       } else {
-               return string();
-       }
+       return canonical_path (path);
 }
 
 string