Skip to content

Commit 1828c91

Browse files
committed
Fix issue with filesystempopup when not using C:\
1 parent 4d4a0c5 commit 1828c91

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

src/popup/FilesystemPopup.hpp

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#include <vector>
88
#include <sstream>
99
#include <regex>
10+
#ifdef _WIN32
11+
#include <windows.h>
12+
#endif
1013

1114
#include "../Window.hpp"
1215
#include "../Theme.hpp"
@@ -399,20 +402,38 @@ class FilesystemPopup : public Popup {
399402
// currentDirectory = MenuItems::ExportDirectory();
400403
// return;
401404
// }
405+
selected.clear();
406+
407+
#ifdef _WIN32
408+
std::vector<char> drives(256);
409+
DWORD size = GetLogicalDriveStringsA(drives.size(), drives.data());
402410

403-
if (std::filesystem::exists("C:\\Program Files (x86)\\Steam\\steamapps\\common\\Rain World\\RainWorld_Data\\StreamingAssets")) {
404-
currentDirectory = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Rain World\\RainWorld_Data\\StreamingAssets";
411+
if (size == 0) {
412+
std::cerr << "Failed to get drives." << std::endl;
405413
return;
406414
}
407415

408-
std::filesystem::path dir = std::filesystem::path(std::getenv("HOME")) / ".steam/steam/steamapps/common/Rain World/RainWorld_Data/StreamingAssets";
409-
if (std::filesystem::exists(dir)) {
410-
currentDirectory = dir;
411-
return;
416+
std::string targetPath = "Program Files (x86)\\Steam\\steamapps\\common\\Rain World\\RainWorld_Data\\StreamingAssets";
417+
418+
for (char* drive = drives.data(); *drive; drive += std::strlen(drive) + 1) {
419+
std::filesystem::path potentialPath = std::filesystem::path(drive) / targetPath;
420+
421+
if (std::filesystem::exists(potentialPath)) {
422+
currentDirectory = potentialPath.string();
423+
return;
424+
}
425+
}
426+
#endif
427+
428+
if (std::getenv("HOME") != nullptr) {
429+
std::filesystem::path dir = std::filesystem::path(std::getenv("HOME")) / ".steam/steam/steamapps/common/Rain World/RainWorld_Data/StreamingAssets";
430+
if (std::filesystem::exists(dir)) {
431+
currentDirectory = dir;
432+
return;
433+
}
412434
}
413435

414436
currentDirectory = std::filesystem::canonical(BASE_PATH);
415-
selected.clear();
416437
}
417438

418439
void refresh() {

0 commit comments

Comments
 (0)