summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-02-17 16:29:25 +0100
committerRobin Gareus <robin@gareus.org>2016-02-17 16:29:25 +0100
commit5e50a7d6cfe76f04d018f5695fd47cc837c1fb24 (patch)
treeb89c14b79712d4566ba8dd904af7a4b760080e57
parent90efd9f0100d191668b8e320664768499ade88df (diff)
allot to open OSX Finder with arbitrary paths
-rw-r--r--libs/ardour/session_directory.cc2
-rw-r--r--libs/pbd/openuri.cc17
-rw-r--r--libs/pbd/pbd/openuri.h1
3 files changed, 19 insertions, 1 deletions
diff --git a/libs/ardour/session_directory.cc b/libs/ardour/session_directory.cc
index 693bee2a1c..3a4d049e3a 100644
--- a/libs/ardour/session_directory.cc
+++ b/libs/ardour/session_directory.cc
@@ -163,7 +163,7 @@ SessionDirectory::sources_root () const
root_cache[m_root_path] = Glib::build_filename (sources_root_path, entries.front());
}
else if (entries.size() > 1) {
- PBD::open_uri (sources_root_path);
+ PBD::open_folder (sources_root_path);
PBD::fatal << string_compose (_("The session's interchange dir is tainted.\nThere is more than one folder in '%1'.\nPlease remove extra subdirs to reduce possible filename ambiguties."), sources_root_path) << endmsg;
assert (0); // not reached
}
diff --git a/libs/pbd/openuri.cc b/libs/pbd/openuri.cc
index 5e7e8f5a02..f96150f5db 100644
--- a/libs/pbd/openuri.cc
+++ b/libs/pbd/openuri.cc
@@ -29,6 +29,7 @@
#include "pbd/openuri.h"
#ifdef __APPLE__
+#include <curl/curl.h>
extern bool cocoa_open_url (const char*);
#endif
@@ -77,3 +78,19 @@ PBD::open_uri (const std::string& uri)
{
return open_uri (uri.c_str());
}
+
+bool
+PBD::open_folder (const std::string& d)
+{
+#ifdef __APPLE__
+ CURL *curl = curl_easy_init ();
+ if (curl) {
+ char * e = curl_easy_escape (curl, d.c_str(), d.size());
+ std::string url = "file:///" + std::string(e);
+ PBD::open_uri (url);
+ curl_free (e);
+ }
+#else
+ PBD::open_uri (d);
+#endif
+}
diff --git a/libs/pbd/pbd/openuri.h b/libs/pbd/pbd/openuri.h
index 64ae46b1d9..f3b8323ed0 100644
--- a/libs/pbd/pbd/openuri.h
+++ b/libs/pbd/pbd/openuri.h
@@ -27,6 +27,7 @@
namespace PBD {
LIBPBD_API bool open_uri (const char*);
LIBPBD_API bool open_uri (const std::string&);
+ LIBPBD_API bool open_folder (const std::string&);
}
#endif