From 8090b641248e41334c76c5fead274f01d7d287a2 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 15 Jan 2012 17:26:18 +0000 Subject: Create savegames/ directory if it doesn't exist. --- src/client/savegamemenu.cc | 9 +++++++++ 1 file changed, 9 insertions(+) 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; -- cgit v1.2.3