Use macOS API to open finder at given path
This commit is contained in:
parent
201617f03b
commit
cd7c981e6e
@ -18,3 +18,12 @@ cocoa_open_url (const char* uri)
|
|||||||
|
|
||||||
return ret;
|
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;
|
||||||
|
}
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include <boost/algorithm/string.hpp>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <glibmm/spawn.h>
|
#include <glibmm/spawn.h>
|
||||||
|
|
||||||
@ -31,8 +30,8 @@
|
|||||||
#include "pbd/openuri.h"
|
#include "pbd/openuri.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <curl/curl.h>
|
|
||||||
extern bool cocoa_open_url (const char*);
|
extern bool cocoa_open_url (const char*);
|
||||||
|
extern bool cocoa_open_folder (const char*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PLATFORM_WINDOWS
|
#ifdef PLATFORM_WINDOWS
|
||||||
@ -100,18 +99,7 @@ bool
|
|||||||
PBD::open_folder (const std::string& d)
|
PBD::open_folder (const std::string& d)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
CURL *curl = curl_easy_init ();
|
return cocoa_open_folder (d.c_str());
|
||||||
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;
|
|
||||||
#else
|
#else
|
||||||
return PBD::open_uri (d);
|
return PBD::open_uri (d);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user