mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-02 13:51:52 +00:00
- make shell folder functions unicode aware
This commit is contained in:
parent
ee132372d8
commit
64824430fa
1 changed files with 31 additions and 18 deletions
|
@ -54,6 +54,7 @@
|
|||
#include <process.h>
|
||||
#include <time.h>
|
||||
#include <map>
|
||||
#include <codecvt>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
@ -66,8 +67,6 @@
|
|||
|
||||
#include <shellapi.h>
|
||||
|
||||
#include <direct.h>
|
||||
|
||||
#include "hardware.h"
|
||||
#include "printf.h"
|
||||
|
||||
|
@ -962,35 +961,49 @@ void I_SetThreadNumaNode(std::thread &thread, int numaNode)
|
|||
}
|
||||
}
|
||||
|
||||
void I_OpenShellFolder(const char* folder)
|
||||
void I_OpenShellFolder(const char* infolder)
|
||||
{
|
||||
char curdir[256];
|
||||
if (!getcwd (curdir, countof(curdir)))
|
||||
LPWSTR curdir = new wchar_t[MAX_PATH];
|
||||
if (!GetCurrentDirectoryW(MAX_PATH, curdir))
|
||||
{
|
||||
Printf ("Current path too long\n");
|
||||
return;
|
||||
}
|
||||
|
||||
chdir(folder);
|
||||
Printf("Opening folder: %s\n", folder);
|
||||
std::system("explorer .");
|
||||
chdir(curdir);
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||
std::wstring folder = converter.from_bytes(infolder);
|
||||
SetCurrentDirectoryW(folder.c_str());
|
||||
Printf("Opening folder: %s\n", infolder);
|
||||
ShellExecuteW(NULL, L"open", L"explorer.exe", L".", NULL, SW_SHOWNORMAL);
|
||||
SetCurrentDirectoryW(curdir);
|
||||
delete curdir;
|
||||
}
|
||||
|
||||
void I_OpenShellFile(const char* file)
|
||||
{
|
||||
char curdir[256];
|
||||
if (!getcwd (curdir, countof(curdir)))
|
||||
LPWSTR curdir = new wchar_t[MAX_PATH];
|
||||
if (!GetCurrentDirectoryW(MAX_PATH, 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);
|
||||
std::string infolder = file;
|
||||
std::string toreplace = "\\";
|
||||
std::string replacewith = "/";
|
||||
std::size_t pos = infolder.find(toreplace);
|
||||
while(pos != std::string::npos)
|
||||
{
|
||||
infolder.replace(pos, toreplace.length(), replacewith);
|
||||
pos = infolder.find(toreplace);
|
||||
}
|
||||
infolder.erase(infolder.find_last_of('/'), std::string::npos);
|
||||
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||
std::wstring folder = converter.from_bytes(infolder);
|
||||
SetCurrentDirectoryW(folder.c_str());
|
||||
Printf("Opening folder: %s\n", infolder.c_str());
|
||||
ShellExecuteW(NULL, L"open", L"explorer.exe", L".", NULL, SW_SHOWNORMAL);
|
||||
SetCurrentDirectoryW(curdir);
|
||||
delete curdir;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue