This commit is contained in:
Rachael Alexanderson 2022-08-15 21:35:36 -04:00
parent a9cadd345d
commit ee132372d8

View file

@ -66,6 +66,8 @@
#include <shellapi.h> #include <shellapi.h>
#include <direct.h>
#include "hardware.h" #include "hardware.h"
#include "printf.h" #include "printf.h"
@ -962,19 +964,33 @@ void I_SetThreadNumaNode(std::thread &thread, int numaNode)
void I_OpenShellFolder(const char* folder) void I_OpenShellFolder(const char* folder)
{ {
FString proc = folder; char curdir[256];
proc.ReplaceChars('/', '\\'); if (!getcwd (curdir, countof(curdir)))
Printf("Opening folder: %s\n", proc.GetChars()); {
proc.Format("\"%s\"", proc.GetChars()); Printf ("Current path too long\n");
ShellExecuteW(NULL, L"open", L"explorer.exe", proc.WideString().c_str(), NULL, SW_SHOWNORMAL); return;
}
chdir(folder);
Printf("Opening folder: %s\n", folder);
std::system("explorer .");
chdir(curdir);
} }
void I_OpenShellFile(const char* file) void I_OpenShellFile(const char* file)
{ {
FString proc = file; char curdir[256];
proc.ReplaceChars('/', '\\'); if (!getcwd (curdir, countof(curdir)))
Printf("Opening folder to file: %s\n", proc.GetChars()); {
proc.Format("/select,\"%s\"", proc.GetChars()); Printf ("Current path too long\n");
ShellExecuteW(NULL, L"open", L"explorer.exe", proc.WideString().c_str(), NULL, SW_SHOWNORMAL); 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);
} }