allot to open OSX Finder with arbitrary paths
authorRobin Gareus <robin@gareus.org>
Wed, 17 Feb 2016 15:29:25 +0000 (16:29 +0100)
committerRobin Gareus <robin@gareus.org>
Wed, 17 Feb 2016 15:29:25 +0000 (16:29 +0100)
libs/ardour/session_directory.cc
libs/pbd/openuri.cc
libs/pbd/pbd/openuri.h

index 693bee2a1c444c2546e9ea8608cd9ad45a7c4ca1..3a4d049e3a1b38ab322e50232d72ce1512268989 100644 (file)
@@ -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
                }
index 5e7e8f5a022bf653e3f08ebf9ecb069c40493c6b..f96150f5db78a96483a495489c1e3f3aca8028b1 100644 (file)
@@ -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
+}
index 64ae46b1d93e535cddbb35c19a4eba51e6acf798..f3b8323ed0152f3753668b2526ed30754d747a89 100644 (file)
@@ -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