commit 42f8ed5f
Comments
git-svn-id: https://blockattack.svn.sourceforge.net/svnroot/blockattack/trunk@65 9d7177f8-192b-0410-8f35-a16a89829b06
Changed files
| M | source/code/common.cc before |
| M | source/code/common.h before |
| M | source/code/main.cpp before |
diff --git a/source/code/common.cc b/source/code/common.cc
index b029fba..0eec6bd 100644
--- a/source/code/common.cc
+++ b/source/code/common.cc
@@ -251,6 +251,13 @@ bool Config::exists(string varName)
return configMap.find(varName) != configMap.end();
}
+void Config::setDefault(string varName,string content)
+{
+ if(exists(varName))
+ return; //Already exists do not change
+ setString(varName,content);
+}
+
void Config::setString(string varName, string content)
{
configMap[varName] = content;
diff --git a/source/code/common.h b/source/code/common.h
index e18a377..77c6d51 100644
--- a/source/code/common.h
+++ b/source/code/common.h
@@ -144,6 +144,12 @@ public:
*version.
*/
bool exists(string varName);
+
+ /*setDefault(varName,value)
+ *if the variable "varName" does not exist it will be created with value "value"
+ *if varName exists then this will have no effect
+ */
+ void setDefault(string varName, string content);
};
#endif /* _COMMON_H */
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 29dcac1..cd7903a 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -3249,9 +3249,13 @@ int main(int argc, char *argv[])
//We first create the folder there we will save (only on UNIX systems)
//we call the external command "mkdir"... the user might have renamed this, but we hope he hasn't
#if defined(__unix__)
- system("mkdir -p ~/.gamesaves/blockattack/screenshots");
- system("mkdir -p ~/.gamesaves/blockattack/replays");
- system("mkdir -p ~/.gamesaves/blockattack/puzzles");
+ //Compiler warns about unused result. The users envisonment should normally give the user all the information he needs
+ if(system("mkdir -p ~/.gamesaves/blockattack/screenshots"))
+ cout << "mkdir error creating ~/.gamesaves/blockattack/screenshots" << endl;
+ if(system("mkdir -p ~/.gamesaves/blockattack/replays"))
+ cout << "mkdir error creating ~/.gamesaves/blockattack/replays" << endl;
+ if(system("mkdir -p ~/.gamesaves/blockattack/puzzles"))
+ cout << "mkdir error creating ~/.gamesaves/blockattack/puzzles" << endl;
#elif defined(_WIN32)
//Now for Windows NT/2k/xp/2k3 etc.
string tempA = getMyDocumentsPath()+"\\My Games";