Added code to create a config file path for win32. This code uses the "AppData" environment variable instead of the shell api call to prevent library dependencies. If the environment variable is not found, the current directory is used.

This commit is contained in:
lotodore
2007-01-21 01:06:38 +00:00
parent b58f802003
commit 2b454df7ce
+21 -1
View File
@@ -21,6 +21,11 @@
#include "game.h"
#include "guiinterface.h"
#include "tinyxml.h"
#include <cstdlib>
#ifdef _WIN32
#include <direct.h>
#endif
using namespace std;
@@ -32,9 +37,24 @@ Session::Session(GuiInterface* g) : actualGame(0), myGui(g)
// Session an mainwindowimpl bergeben
myGui->setSession(this);
//Konfiguration erstellen;
// Konfiguration erstellen
string configFileName;
#ifdef _WIN32
const char *appDataPath = getenv("AppData");
if (appDataPath)
{
configFileName = appDataPath;
configFileName += "\\pokerth\\";
mkdir(configFileName.c_str());
}
#else
// hier Linux/Mac Code zur Basispfadbestimmung, z.B.
configFileName = "~/pokerth";
// wenn nicht existiert, erzeugen!
#endif
configFileName += "config.xml";
}