From 09e471545bd1c41f474e733cc404867d87e87d49 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:57:16 -0400 Subject: remove direct of realpath(2), replace with canonical_path() which is a no-op on windows --- libs/pbd/pathexpand.cc | 27 +++++++++++++++++++-------- libs/pbd/pbd/pathexpand.h | 1 + 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'libs/pbd') 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 -#include #include +#include +#include +#include #include @@ -31,6 +33,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) { @@ -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 diff --git a/libs/pbd/pbd/pathexpand.h b/libs/pbd/pbd/pathexpand.h index a7b9f7557a..2b2639e07e 100644 --- a/libs/pbd/pbd/pathexpand.h +++ b/libs/pbd/pbd/pathexpand.h @@ -22,6 +22,7 @@ #include namespace PBD { + std::string canonical_path (const std::string& path); std::string path_expand (std::string path); std::string search_path_expand (std::string path); } -- cgit v1.2.3