Skip to content

Commit dbe14eb

Browse files
committed
Add option to show game paths
1 parent f8ae86e commit dbe14eb

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎src/Engine/CrossPlatform.cpp‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <windows.h>
4141
#include <shlobj.h>
4242
#include <shlwapi.h>
43+
#include <shellapi.h>
4344
#ifndef __NO_DBGHELP
4445
#include <dbghelp.h>
4546
#endif
@@ -1178,6 +1179,23 @@ void crashDump(void *ex, const std::string &err)
11781179
showError(msg.str());
11791180
}
11801181

1182+
/**
1183+
* Opens a file or web path in the system default browser.
1184+
*/
1185+
bool openExplorer(const std::string &url)
1186+
{
1187+
#ifdef _WIN32
1188+
HINSTANCE ret = ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
1189+
// The return value is not a true HINSTANCE. If the function succeeds, it returns a value greater than 32.
1190+
return ((int)ret > 32);
1191+
#elif __APPLE__
1192+
return false;
1193+
#else
1194+
std::string cmd = "xdg-open \"" + url + "\"";
1195+
return (system(cmd.c_str()) == 0);
1196+
#endif
1197+
}
1198+
11811199
}
11821200

11831201
}

‎src/Engine/CrossPlatform.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ namespace CrossPlatform
9999
std::string now();
100100
/// Produces a crash dump.
101101
void crashDump(void *ex, const std::string &err);
102+
/// Opens a URL.
103+
bool openExplorer(const std::string &url);
102104
}
103105

104106
}

0 commit comments

Comments
 (0)