Skip to content

Commit e463192

Browse files
authored
Merge pull request #6083 from fluffyfreak/fix-savegamedump
Read/write save games from/to the savefiles folder
2 parents 979ab5f + ea87ee4 commit e463192

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/savegamedump.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#include "core/GZipFormat.h"
77
#include <SDL.h>
88

9+
// HACK, this is copied from /src/SaveGameManager.cpp where it is defined
10+
static const char s_saveDirName[] = "savefiles";
11+
912
int info()
1013
{
1114
printf(
@@ -32,14 +35,14 @@ extern "C" int main(int argc, char **argv)
3235
filename = argv[shift+1];
3336
std::string outname = argc > shift+2 ? argv[shift+2] : filename + ".json";
3437

35-
auto fileinfo = FileSystem::userFiles.Lookup(filename);
38+
auto fileinfo = FileSystem::userFiles.Lookup(FileSystem::JoinPathBelow(s_saveDirName, filename));
3639
if (!fileinfo.Exists()) {
3740
printf("Input file %s could not be found.\n", filename.c_str());
3841
printf("%s\n", fileinfo.GetPath().c_str());
3942
return 1;
4043
}
4144

42-
auto file = FileSystem::userFiles.ReadFile(filename);
45+
auto file = FileSystem::userFiles.ReadFile(FileSystem::JoinPathBelow(s_saveDirName, filename));
4346
if (!file) {
4447
printf("Could not open file %s.\n", filename.c_str());
4548
return 1;
@@ -74,7 +77,7 @@ extern "C" int main(int argc, char **argv)
7477
return 3;
7578
}
7679

77-
auto outFile = FileSystem::userFiles.OpenWriteStream(outname);
80+
auto outFile = FileSystem::userFiles.OpenWriteStream(FileSystem::JoinPathBelow(s_saveDirName, outname));
7881
if (!outFile) {
7982
printf("Could not open output file %s.\n", outname.c_str());
8083
return 1;

0 commit comments

Comments
 (0)