--- AE/Installer/trunk/source/installer.cpp 2009/12/30 01:51:38 487 +++ AE/Installer/trunk/source/installer.cpp 2010/02/22 00:00:55 496 @@ -9,8 +9,11 @@ // TODO: Load credits from text resource file // TODO: Clear mod info fields when mod is de-selected -#define DEBUG - +//#define DEBUG +#ifdef WIN32 +//#include +#define popen _popen +#endif #include "boost/date_time/gregorian/gregorian.hpp" #include "boost/date_time/date_parsing.hpp" #include "boost/date_time/posix_time/posix_time.hpp" @@ -1139,6 +1142,7 @@ bool ProcessInstallerUpdate(Install_info string popenCommand = "../updates/" + strEUFN + "/install/"; #ifdef WIN32 // TODO: Fill in Windows equivalent of code below :-3 + popenCommand = "replace_installer.bat"; #else // We can't just use '~' to mean "the home directory" because we need to check the path in C... // ...so we actually get the current user's shortname and manually construct the path to home @@ -1160,8 +1164,11 @@ bool ProcessInstallerUpdate(Install_info #endif file.close(); file.clear(); +#ifdef WIN32 + system(popenCommand.c_str()); +#else popen(popenCommand.c_str(), "r"); - +#endif return true; // returning 'true' tells the Installer to quit itself ASAP so it can be replaced by the process that is now running } @@ -1192,7 +1199,7 @@ bool ProcessAEUpdate(Install_info_cfg *c // TODO: Fill in Windows equivalent of code below #ifdef WIN32 - string strTrashDir = "%RECYCLE%"; + string strTrashDir = "Trash\\"; #else FILE *fUserName = NULL; char chrUserName[32]; @@ -1237,7 +1244,7 @@ bool ProcessAEUpdate(Install_info_cfg *c needNewTrashDir = true; } } - +#ifndef WIN32 if (!*installerJustUpdated || needNewTrashDir) // prepare a new directory for deleted files to go to { tm tmStartTime = to_tm(startTime); @@ -1245,6 +1252,7 @@ bool ProcessAEUpdate(Install_info_cfg *c boost::lexical_cast(tmStartTime.tm_min) + "-" + boost::lexical_cast(tmStartTime.tm_sec) + "/"; create_directory(strTrashDir); } +#endif file.close(); file.clear(); @@ -1279,9 +1287,9 @@ bool ProcessAEUpdate(Install_info_cfg *c if (exists(strPathToEUFNInstall + strWinGUI)) { if (exists((path)strWinGUI)) - rename((path)strWinGUI, (path)strcat(strTrashDir, strWinGUI)); + rename((path)strWinGUI, (path)(strTrashDir + strWinGUI)); if (exists(strWinGUILang)) - rename((path)strWinGUILang, (path)strcat(strTrashDir, strWinGUILang)); + rename((path)strWinGUILang, (path)(strTrashDir + strWinGUILang)); rename((path)(strPathToEUFNInstall + strWinGUI), (path)strWinGUI); rename((path)(strPathToEUFNInstall + strWinGUILang), (path)strWinGUILang); } @@ -1320,7 +1328,11 @@ bool ProcessAEUpdate(Install_info_cfg *c curPos = thePath.find("/", lastPos); aParentPath = aParentPath + "/"; } +#ifndef WIN32 rename((path)("../" + thePath), (path)(strTrashDir + thePath)); +#else + remove((path)("../" + thePath)); +#endif } } @@ -1343,7 +1355,11 @@ bool ProcessAEUpdate(Install_info_cfg *c matchFound = true; if (iter1->modStringVersion > iter2->modStringVersion) { +#ifndef WIN32 rename((path)(strPathToPackages + iter2->modStringName), (path)(strTrashDir + iter2->modStringName)); +#else + remove((path)(strPathToPackages + iter2->modStringName)); +#endif rename((path)(strPathToEUFNPackages + iter1->modStringName), (path)(strPathToPackages + iter1->modStringName)); } } @@ -1579,12 +1595,12 @@ ModPackage::ModPackage() readme = ""; globalNeeded = true; } - +#ifndef WIN32 void Sleep(int ms) { sleep(ms / 1000); } - +#endif #ifdef WIN32 void RedirectIOToConsole()