summaryrefslogtreecommitdiff
path: root/libs/pbd/pathexpand.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-07-11 14:57:16 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-07-11 14:57:16 -0400
commit09e471545bd1c41f474e733cc404867d87e87d49 (patch)
treed58274312a20b08b3b99fcea99f9a0c00998ce31 /libs/pbd/pathexpand.cc
parent2ddab2d2f6738f9c1dc0dd31a12cdeb6b7fe540e (diff)
remove direct of realpath(2), replace with canonical_path() which is a no-op on windows
Diffstat (limited to 'libs/pbd/pathexpand.cc')
-rw-r--r--libs/pbd/pathexpand.cc27
1 files changed, 19 insertions, 8 deletions
diff --git a/libs/pbd/pathexpand.cc b/libs/pbd/pathexpand.cc
index 4911f12788..ad53bea37b 100644
--- a/libs/pbd/pathexpand.cc
+++ b/libs/pbd/pathexpand.cc
@@ -18,8 +18,10 @@
*/
#include <vector>
-#include <climits>
#include <iostream>
+#include <climits>
+#include <cerrno>
+#include <cstdlib>
#include <regex.h>
@@ -32,6 +34,21 @@ using std::string;
using std::vector;
string
+PBD::canonical_path (const std::string& path)
+{
+#ifdef WIN32
+ return path;
+#endif
+ char buf[PATH_MAX+1];
+
+ if (!realpath (path.c_str(), buf) && (errno != ENOENT)) {
+ return path;
+ }
+
+ return string (buf);
+}
+
+string
PBD::path_expand (string path)
{
if (path.empty()) {
@@ -97,13 +114,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