Windows: Switch to preferred file selection method.

It seems like the previous may not support long paths.
This commit is contained in:
Unknown W. Brackets 2021-10-09 15:58:49 -07:00
parent 08a55d19d5
commit 8d29aa6590
2 changed files with 13 additions and 6 deletions

View file

@ -191,10 +191,13 @@ PermissionStatus System_GetPermissionStatus(SystemPermission permission) { retur
void OpenDirectory(const char *path) {
#if PPSSPP_PLATFORM(WINDOWS)
PIDLIST_ABSOLUTE pidl = ILCreateFromPath(ConvertUTF8ToWString(ReplaceAll(path, "/", "\\")).c_str());
SFGAOF flags;
PIDLIST_ABSOLUTE pidl = nullptr;
HRESULT hr = SHParseDisplayName(ConvertUTF8ToWString(ReplaceAll(path, "/", "\\")).c_str(), nullptr, &pidl, 0, &flags);
if (pidl) {
SHOpenFolderAndSelectItems(pidl, 0, NULL, 0);
ILFree(pidl);
if (SUCCEEDED(hr))
SHOpenFolderAndSelectItems(pidl, 0, NULL, 0);
CoTaskMemFree(pidl);
}
#elif PPSSPP_PLATFORM(MAC)
std::string command = std::string("open ") + path;

View file

@ -108,10 +108,14 @@ static std::thread inputBoxThread;
static bool inputBoxRunning = false;
void OpenDirectory(const char *path) {
PIDLIST_ABSOLUTE pidl = ILCreateFromPath(ConvertUTF8ToWString(ReplaceAll(path, "/", "\\")).c_str());
SFGAOF flags;
PIDLIST_ABSOLUTE pidl = nullptr;
HRESULT hr = SHParseDisplayName(ConvertUTF8ToWString(ReplaceAll(path, "/", "\\")).c_str(), nullptr, &pidl, 0, &flags);
if (pidl) {
SHOpenFolderAndSelectItems(pidl, 0, NULL, 0);
ILFree(pidl);
if (SUCCEEDED(hr))
SHOpenFolderAndSelectItems(pidl, 0, nullptr, 0);
CoTaskMemFree(pidl);
}
}