From a9cadd345d5a5b8f529edb21da1bf7a814ad4318 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 14 Aug 2022 18:37:53 -0400 Subject: [PATCH] - change the way posix folders are opened - fixes issue #1707 --- src/common/platform/posix/cocoa/i_system.mm | 30 ++++++++++++++++----- src/common/platform/posix/sdl/i_system.cpp | 29 +++++++++++++++----- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/common/platform/posix/cocoa/i_system.mm b/src/common/platform/posix/cocoa/i_system.mm index f83536d53..6d50e718d 100644 --- a/src/common/platform/posix/cocoa/i_system.mm +++ b/src/common/platform/posix/cocoa/i_system.mm @@ -173,15 +173,33 @@ unsigned int I_MakeRNGSeed() void I_OpenShellFolder(const char* folder) { - std::string x = (std::string)"open \"" + (std::string)folder + "\""; + char curdir[256]; + if (!getcwd (curdir, countof(curdir))) + { + Printf ("Current path too long\n"); + return; + } + + chdir(folder); Printf("Opening folder: %s\n", folder); - std::system(x.c_str()); + std::system("open ."); + chdir(curdir); } void I_OpenShellFile(const char* file) { - std::string x = (std::string)"open \"" + (std::string)file + "\""; - x.erase(x.find_last_of('/'), std::string::npos); - Printf("Opening folder to file: %s\n", file); - std::system(x.c_str()); + char curdir[256]; + if (!getcwd (curdir, countof(curdir))) + { + Printf ("Current path too long\n"); + return; + } + + std::string folder = file; + folder.erase(folder.find_last_of('/'), std::string::npos); + chdir(folder.c_str()); + Printf("Opening folder: %s\n", folder.c_str()); + std::system("open ."); + chdir(curdir); } + diff --git a/src/common/platform/posix/sdl/i_system.cpp b/src/common/platform/posix/sdl/i_system.cpp index d96613494..68b6bd12d 100644 --- a/src/common/platform/posix/sdl/i_system.cpp +++ b/src/common/platform/posix/sdl/i_system.cpp @@ -434,16 +434,33 @@ unsigned int I_MakeRNGSeed() void I_OpenShellFolder(const char* folder) { - std::string x = (std::string)"xdg-open \"" + (std::string)folder + "\""; + char curdir[256]; + if (!getcwd (curdir, countof(curdir))) + { + Printf ("Current path too long\n"); + return; + } + + chdir(folder); Printf("Opening folder: %s\n", folder); - std::system(x.c_str()); + std::system("xdg-open ."); + chdir(curdir); } void I_OpenShellFile(const char* file) { - std::string x = (std::string)"xdg-open \"" + (std::string)file + "\""; - x.erase(x.find_last_of('/'), std::string::npos); - Printf("Opening folder to file: %s\n", file); - std::system(x.c_str()); + char curdir[256]; + if (!getcwd (curdir, countof(curdir))) + { + Printf ("Current path too long\n"); + return; + } + + std::string folder = file; + folder.erase(folder.find_last_of('/'), std::string::npos); + chdir(folder.c_str()); + Printf("Opening folder: %s\n", folder.c_str()); + std::system("xdg-open ."); + chdir(curdir); }