File tree Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Original file line number Diff line number Diff line change 7
7
#include < vector>
8
8
#include < sstream>
9
9
#include < regex>
10
+ #ifdef _WIN32
11
+ #include < windows.h>
12
+ #endif
10
13
11
14
#include " ../Window.hpp"
12
15
#include " ../Theme.hpp"
@@ -399,20 +402,38 @@ class FilesystemPopup : public Popup {
399
402
// currentDirectory = MenuItems::ExportDirectory();
400
403
// return;
401
404
// }
405
+ selected.clear ();
406
+
407
+ #ifdef _WIN32
408
+ std::vector<char > drives (256 );
409
+ DWORD size = GetLogicalDriveStringsA (drives.size (), drives.data ());
402
410
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 ;
405
413
return ;
406
414
}
407
415
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
+ }
412
434
}
413
435
414
436
currentDirectory = std::filesystem::canonical (BASE_PATH);
415
- selected.clear ();
416
437
}
417
438
418
439
void refresh () {
You can’t perform that action at this time.
0 commit comments