From ee132372d8287b99824e3d5c1f5a3f4a41306f1c Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 15 Aug 2022 21:35:36 -0400 Subject: [PATCH] - patch for this note: https://github.com/ZDoom/gzdoom/commit/03d76027cfb35a0c7c5a5602b4f990fdc5aa9419#commitcomment-81265953 --- src/common/platform/win32/i_system.cpp | 36 +++++++++++++++++++------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/common/platform/win32/i_system.cpp b/src/common/platform/win32/i_system.cpp index bbbd309a8..48005a428 100644 --- a/src/common/platform/win32/i_system.cpp +++ b/src/common/platform/win32/i_system.cpp @@ -66,6 +66,8 @@ #include +#include + #include "hardware.h" #include "printf.h" @@ -962,19 +964,33 @@ void I_SetThreadNumaNode(std::thread &thread, int numaNode) void I_OpenShellFolder(const char* folder) { - FString proc = folder; - proc.ReplaceChars('/', '\\'); - Printf("Opening folder: %s\n", proc.GetChars()); - proc.Format("\"%s\"", proc.GetChars()); - ShellExecuteW(NULL, L"open", L"explorer.exe", proc.WideString().c_str(), NULL, SW_SHOWNORMAL); + 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("explorer ."); + chdir(curdir); } void I_OpenShellFile(const char* file) { - FString proc = file; - proc.ReplaceChars('/', '\\'); - Printf("Opening folder to file: %s\n", proc.GetChars()); - proc.Format("/select,\"%s\"", proc.GetChars()); - ShellExecuteW(NULL, L"open", L"explorer.exe", proc.WideString().c_str(), NULL, SW_SHOWNORMAL); + 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("explorer ."); + chdir(curdir); }