From cd7c981e6eaa937d16cffc8ae049ddde27f7f30e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 8 Dec 2022 02:11:06 +0100 Subject: [PATCH] Use macOS API to open finder at given path --- libs/pbd/cocoa_open_uri.mm | 9 +++++++++ libs/pbd/openuri.cc | 16 ++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/libs/pbd/cocoa_open_uri.mm b/libs/pbd/cocoa_open_uri.mm index 90a3995d71..ed4c2b25d5 100644 --- a/libs/pbd/cocoa_open_uri.mm +++ b/libs/pbd/cocoa_open_uri.mm @@ -18,3 +18,12 @@ cocoa_open_url (const char* uri) return ret; } + +bool +cocoa_open_folder (const char* path) +{ + NSString* struri = [[NSString alloc] initWithUTF8String:path]; + bool rv = [[NSWorkspace sharedWorkspace] selectFile:nil inFileViewerRootedAtPath:struri]; + [struri release]; + return rv; +} diff --git a/libs/pbd/openuri.cc b/libs/pbd/openuri.cc index 780f46fb74..648b60dbda 100644 --- a/libs/pbd/openuri.cc +++ b/libs/pbd/openuri.cc @@ -23,7 +23,6 @@ #endif #include - #include #include #include @@ -31,8 +30,8 @@ #include "pbd/openuri.h" #ifdef __APPLE__ -#include extern bool cocoa_open_url (const char*); + extern bool cocoa_open_folder (const char*); #endif #ifdef PLATFORM_WINDOWS @@ -100,18 +99,7 @@ bool PBD::open_folder (const std::string& d) { #ifdef __APPLE__ - CURL *curl = curl_easy_init (); - bool rv = false; - if (curl) { - char * e = curl_easy_escape (curl, d.c_str(), d.size()); - std::string p (e); - boost::replace_all (p, "%2F", "/"); - std::string url = "file://" + p; - rv = PBD::open_uri (url); - curl_free (e); - curl_easy_cleanup(curl); - } - return rv; + return cocoa_open_folder (d.c_str()); #else return PBD::open_uri (d); #endif