From 5e50a7d6cfe76f04d018f5695fd47cc837c1fb24 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 17 Feb 2016 16:29:25 +0100 Subject: [PATCH] allot to open OSX Finder with arbitrary paths --- libs/ardour/session_directory.cc | 2 +- libs/pbd/openuri.cc | 17 +++++++++++++++++ libs/pbd/pbd/openuri.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) 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 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