--- AE/Installer/trunk/source/installer.cpp 2010/01/24 23:58:16 489 +++ AE/Installer/trunk/source/installer.cpp 2010/03/03 02:09:02 499 @@ -939,6 +939,7 @@ bool ReadInstallInfoCfg(fstream *fileHan while (getline(*fileHandler, line)) { + StripNewlines(&line); tokenize(line, tokens); iter = tokens.begin(); @@ -1142,6 +1143,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 @@ -1163,8 +1165,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 } @@ -1195,7 +1200,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]; @@ -1240,7 +1245,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); @@ -1248,6 +1253,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(); @@ -1323,7 +1329,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 } } @@ -1346,7 +1356,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)); } } @@ -1457,6 +1471,17 @@ void tokenize(const string& str, vector< } } +/* StripNewlines() gets rids of any linebreaks that come from text returned by getline(); \ +| getline() should be stripping those out, but Windows CR/LF files seem to be sneaking | +\ some extra return characters into strings in the ReadInstallInfoCfg() function. */ +void StripNewlines(string *theLine) +{ + int deleteFromHere = 0; + deleteFromHere = theLine->find("\r"); + if (deleteFromHere > 0) + theLine->erase(deleteFromHere, theLine->size()); +} + void clearOldDats(void) { directory_iterator end_iter_gdf; for ( directory_iterator dir_itr_gdf( "../GameDataFolder" );