From 5af6de5aec4ba85cc65fcfa445b6d6567c1d06ee Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sun, 27 Mar 2011 15:16:28 +0000 Subject: [PATCH] - win32 now looks/stores userdata in the default windows appdata folder: C:\Documents and Settings\All Users\Application Data\megaglest (all dev users should copy all contents of mydata into this new location).. NOT INCLUDING the mydata folder itself --- source/shared_lib/sources/util/properties.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/shared_lib/sources/util/properties.cpp b/source/shared_lib/sources/util/properties.cpp index d3c884941..7ee8a1176 100644 --- a/source/shared_lib/sources/util/properties.cpp +++ b/source/shared_lib/sources/util/properties.cpp @@ -18,6 +18,12 @@ #include "conversion.h" #include "util.h" #include "platform_common.h" + +#ifdef WIN32 +#include +#include +#endif + #include "leak_dumper.h" using namespace std; @@ -92,12 +98,26 @@ bool Properties::applyTagsToValue(string &value) { #else homeDir = getenv("HOME"); #endif + replaceAll(value, "~/", (homeDir != NULL ? homeDir : "")); replaceAll(value, "$HOME", (homeDir != NULL ? homeDir : "")); replaceAll(value, "%%HOME%%", (homeDir != NULL ? homeDir : "")); replaceAll(value, "%%USERPROFILE%%",(homeDir != NULL ? homeDir : "")); replaceAll(value, "%%HOMEPATH%%", (homeDir != NULL ? homeDir : "")); + // For win32 we allow use of the appdata variable since that is the recommended + // place for application data in windows platform +#ifdef WIN32 + TCHAR szPath[MAX_PATH]=""; + // Get path for each computer, non-user specific and non-roaming data. + if ( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_COMMON_APPDATA, + NULL, 0, szPath))) { + string appPath = szPath; + replaceAll(value, "$APPDATA", appPath); + replaceAll(value, "%%APPDATA%%", appPath); + } +#endif + char *username = NULL; username = getenv("USERNAME"); replaceAll(value, "$USERNAME", (username != NULL ? username : ""));