MCPcopy Create free account
hub / github.com/HailToDodongo/pyrite64 / openInFileBrowser

Method openInFileBrowser

src/utils/proc.cpp:231–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229}
230
231bool Utils::Proc::openInFileBrowser(const std::string &path)
232{
233#if defined(_WIN32)
234 std::string explorerArgs = "/select," + path;
235 const char* args[] = { "explorer.exe", explorerArgs.c_str(), NULL };
236 SDL_CreateProcess(args, false);
237 return true;
238#elif defined(__APPLE__)
239 const char* args[] = { "open", "-R", path.c_str(), NULL };
240 SDL_CreateProcess(args, false);
241 return true;
242#else
243#if defined(__linux__)
244 if (isWSL()) {
245 const auto windowsPath = wslToWindowsPath(path);
246 if (windowsPath) {
247 std::string explorerArgs = std::string("/select,") + *windowsPath;
248 const char* args[] = { "explorer.exe", explorerArgs.c_str(), NULL };
249 SDL_CreateProcess(args, false);
250 return true;
251 }
252 return false;
253 }
254#endif
255 std::string pathArg = std::format("array:string:file:///{}", path);
256 const char* args[] = {
257 "dbus-send",
258 "--session",
259 "--dest=org.freedesktop.FileManager1",
260 "--type=method_call",
261 "/org/freedesktop/FileManager1",
262 "org.freedesktop.FileManager1.ShowItems",
263 pathArg.c_str(),
264 "string:",
265 NULL
266 };
267 SDL_CreateProcess(args, false);
268 return true;
269#endif
270}
271
272void Utils::Proc::openURL(const std::string &url)
273{

Callers

nothing calls this directly

Calls 2

isWSLFunction · 0.85
wslToWindowsPathFunction · 0.85

Tested by

no test coverage detected