|
30 | 30 | // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// |
31 | 31 | #include "PreRTS.h" |
32 | 32 | #include <filesystem> |
| 33 | +#include "Common/System/NativeFileSystem.h" |
33 | 34 | #ifndef __APPLE__ |
34 | 35 | #include <io.h> |
35 | 36 | #else |
@@ -477,7 +478,7 @@ AsciiString GameState::findNextSaveFilename( UnicodeString desc ) |
477 | 478 | leaf.format("%s_%04d%s", adesc.str(), i, SAVE_GAME_EXTENSION); |
478 | 479 |
|
479 | 480 | AsciiString path = getFilePathInSaveDirectory(leaf); |
480 | | - if( _access( path.str(), 0 ) == -1 ) |
| 481 | + if( !NativeFileSystem::exists(path.str()) ) |
481 | 482 | return leaf; // note that this returns the leaf, not the full path |
482 | 483 | } |
483 | 484 | #else |
@@ -524,7 +525,7 @@ AsciiString GameState::findNextSaveFilename( UnicodeString desc ) |
524 | 525 | fullPath = getFilePathInSaveDirectory(filename); |
525 | 526 |
|
526 | 527 | // if file does not exist we're all good |
527 | | - if( _access( fullPath.str(), 0 ) == -1 ) |
| 528 | + if( !NativeFileSystem::exists(fullPath.str()) ) |
528 | 529 | return filename; |
529 | 530 |
|
530 | 531 | // test the text filename |
@@ -571,7 +572,7 @@ SaveCode GameState::saveGame( AsciiString filename, UnicodeString desc, |
571 | 572 | } |
572 | 573 |
|
573 | 574 | // make absolutely sure the save directory exists |
574 | | - CreateDirectory( getSaveDirectory().str(), nullptr ); |
| 575 | + NativeFileSystem::create_directory( std::string(getSaveDirectory().str()) ); |
575 | 576 |
|
576 | 577 | // construct path to file |
577 | 578 | AsciiString filepath = getFilePathInSaveDirectory(filename); |
@@ -1019,7 +1020,8 @@ void GameState::getSaveGameInfoFromFile( AsciiString filename, SaveGameInfo *sav |
1019 | 1020 |
|
1020 | 1021 | // open file for partial loading |
1021 | 1022 | XferLoad xferLoad; |
1022 | | - xferLoad.open( filename ); |
| 1023 | + AsciiString filepath = getFilePathInSaveDirectory(filename); |
| 1024 | + xferLoad.open( filepath ); |
1023 | 1025 |
|
1024 | 1026 | // |
1025 | 1027 | // disable post processing cause we're not really doing a load of game data that |
@@ -1349,7 +1351,8 @@ void GameState::iterateSaveFiles( IterateSaveFileCallback callback, void *userDa |
1349 | 1351 | #else |
1350 | 1352 | try |
1351 | 1353 | { |
1352 | | - for (const auto& entry : std::filesystem::directory_iterator(getSaveDirectory().str())) |
| 1354 | + std::string safeSaveDir = NativeFileSystem::get_safe_path(getSaveDirectory().str()); |
| 1355 | + for (const auto& entry : std::filesystem::directory_iterator(safeSaveDir)) |
1353 | 1356 | { |
1354 | 1357 | if (entry.is_regular_file()) |
1355 | 1358 | { |
|
0 commit comments