diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index ec2a9473..a97ac084 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -16,15 +16,11 @@ #if defined(_WIN32) #include #include -#include #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__) || defined(__DragonFly__) #include #include #include #include -#include -#include -#include #define MAX_PATH PATH_MAX #endif @@ -561,42 +557,17 @@ bool FILESYSTEM_openDirectoryEnabled() return !SDL_GetHintBoolean("SteamTenfoot", SDL_FALSE); } -#ifdef _WIN32 bool FILESYSTEM_openDirectory(const char *dname) { - ShellExecute(NULL, "open", dname, NULL, NULL, SW_SHOWMINIMIZED); + char url[MAX_PATH]; + SDL_snprintf(url, sizeof(url), "file://%s", dname); + if (SDL_OpenURL(url) == -1) + { + printf("Error opening directory: %s\n", SDL_GetError()); + return false; + } return true; } -#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__) || defined(__DragonFly__) - #if defined(__APPLE__) || defined(__HAIKU__) -const char* open_cmd = "open"; - #else -const char* open_cmd = "xdg-open"; - #endif - -extern "C" char** environ; - -bool FILESYSTEM_openDirectory(const char *dname) -{ - pid_t child; - // This const_cast is legal (ctrl-f "The statement" at https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html - char* argv[3] = - { - const_cast(open_cmd), - const_cast(dname), - NULL - }; - posix_spawnp(&child, open_cmd, NULL, NULL, argv, environ); - int status = 0; - waitpid(child, &status, 0); - return WIFEXITED(status) && WEXITSTATUS(status) == 0; -} -#else -bool FILESYSTEM_openDirectory(const char *dname) -{ - return false; -} -#endif bool FILESYSTEM_delete(const char *name) {