Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-01-15 17:26:18 +0000
committerStijn Buys <ingar@osirion.org>2012-01-15 17:26:18 +0000
commit8090b641248e41334c76c5fead274f01d7d287a2 (patch)
tree17adbd6951d887f121583f69ac432990068befd6
parent534e30270a8636ab8e2cc5e8b750747186dd06af (diff)
Create savegames/ directory if it doesn't exist.
-rw-r--r--src/client/savegamemenu.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/client/savegamemenu.cc b/src/client/savegamemenu.cc
index 9f8ee99..be26cd4 100644
--- a/src/client/savegamemenu.cc
+++ b/src/client/savegamemenu.cc
@@ -13,6 +13,7 @@
#include "client/savegamemenu.h"
#include "filesystem/filesystem.h"
#include "ui/ui.h"
+#include "sys/sys.h"
namespace client
{
@@ -297,6 +298,7 @@ void SaveGameMenu::savegame(std::string savename)
return;
}
+ // find an approriate savegame name if none was specified
if (!savename.size()) {
std::string filename;
unsigned long n = 0;
@@ -312,6 +314,13 @@ void SaveGameMenu::savegame(std::string savename)
} while (sys::file_exists(filename));
}
+ // create savegame diretory if required
+ std::string savegamepath(filesystem::writedir());
+ savegamepath.append("savegames");
+ if (!sys::directory_exists(savegamepath)) {
+ sys::mkdir(savegamepath);
+ }
+
filesystem::OFileStream ofs("savegames/" + savename + ".ini");
con_debug << "Saving " << ofs.filename() << std::endl;