From 054817acd08f28cb6fd8e8b054e1a5ae39fe30c5 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 3 Jul 2010 07:02:31 +0000 Subject: [PATCH] - added auto-create of user ini files if they don't exist --- source/glest_game/global/config.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index 33bf3e43..125680fc 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -19,8 +19,7 @@ #include "conversion.h" #include "window.h" #include -//#include -//#include +#include #include "leak_dumper.h" using namespace Shared::Platform; @@ -82,6 +81,20 @@ Config::Config(std::pair type, std::pair f SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cfgFile.second = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.second.c_str()); } + + try { + if(fileName.second != "" && fileExists(fileName.second) == false) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] attempting to auto-create cfgFile.second = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.second.c_str()); + + std::ofstream userFile; + userFile.open(fileName.second.c_str(), ios_base::out | ios_base::trunc); + userFile.close(); + } + } + catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ERROR trying to auto-create cfgFile.second = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.second.c_str()); + } + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cfgFile.second = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.second.c_str()); }