Skip to content

Commit 5008120

Browse files
committed
Change how Reveal works on macOS
1 parent e836435 commit 5008120

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

source/AppleUtilities.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
#include <cstdint>
3+
#include <filesystem>
34

45
void getCFBundleVersionFromPlist(const char* path, char* outbuf, uint8_t outbuf_size);
56

@@ -9,3 +10,5 @@ enum architecture{
910
arm64 = 1 << 2,
1011
};
1112
int getArchitectureFromBundle(const char* path);
13+
14+
void RevealFile(const std::filesystem::path& p);

source/AppleUtilities.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@ int getArchitectureFromBundle(const char* path){
2929
}
3030
return archmask;
3131
}
32+
33+
void RevealFile(const std::filesystem::path& p){
34+
const auto str = p.string();
35+
auto urlstr = [NSString stringWithUTF8String:str.c_str()];
36+
[[NSWorkspace sharedWorkspace] selectFile:urlstr inFileViewerRootedAtPath:@""];
37+
}

source/globals.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#include <fmt/format.h>
33
#include <wx/listctrl.h>
44
#include <wx/msgdlg.h>
5+
#if __APPLE__
6+
#include "AppleUtilities.h"
7+
#endif
58

69
void launch_process(const std::string& command, int flags) {
710
#if defined __APPLE__ || defined __linux__
@@ -19,9 +22,9 @@ void launch_process(const std::string& command, int flags) {
1922

2023
void reveal_in_explorer(const std::filesystem::path& path) {
2124
#if defined __APPLE__
22-
std::string command = "open \"" + path.string() + "\"";
23-
24-
#elif defined __linux__
25+
RevealFile(path);
26+
#else
27+
#if defined __linux__
2528
std::string command = "xdg-open \"" + path.string() + "\"";
2629

2730
#elif defined _WIN32
@@ -34,7 +37,7 @@ void reveal_in_explorer(const std::filesystem::path& path) {
3437
else {
3538
wxMessageBox("The project at " + path.string() + " could not be found.", "Cannot Reveal Project", wxOK | wxICON_ERROR);
3639
}
37-
40+
#endif
3841
}
3942

4043
long wxListCtrl_get_selected(wxListCtrl* listCtrl) {
@@ -78,4 +81,4 @@ void dpi_scale(wxWindow* window){
7881
float minw = window->GetMinWidth() * fac;
7982
//set the minimum size
8083
window->SetSizeHints(wxSize(minw, minh));
81-
}
84+
}

source/interface_derived.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ void MainFrameDerived::LoadEditorVersions(){
622622
if (!filesystem::exists(infopath)){
623623
// maybe this was a direct install
624624
infopath = entry / "Contents" / "Info.plist";
625-
basedir = entry;
626625
}
627626
if (filesystem::exists(infopath) && infopath.string().find("Unity.app") != std::string::npos){
628627
// read the file and look for CFBundleVersion

0 commit comments

Comments
 (0)