--- AE/Installer/trunk/source/installer.cpp 2010/04/24 17:41:46 507 +++ AE/Installer/trunk/source/installer.cpp 2010/05/24 19:13:59 543 @@ -27,6 +27,7 @@ using namespace boost::posix_time; // externs declared in installer.h string strInstallCfg = "../GameDataFolder/Add.cfg"; string strEUFN = "Edition"; // GetUpdateStatus() may set this to "Edition-patch" later, but this is the assumed name of the new Edition folder in Updates/ +extern MainWindow* TheWindow; int globalizeData(void) { @@ -734,8 +735,10 @@ void copyBSL(string copypath, vectorpath(), "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); } } - BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon - BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; + if( !pkg.hasAddon ) { + BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon + BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; + } } } } @@ -841,8 +844,11 @@ int GetUpdateStatus(Install_info_cfg *cu return UPDATE_LOG_READ_ERR; } - // Is there an update folder, and is it a monthly release or a patch? + // Is there an update in the updates/ folder, and is it a monthly release or a patch? bool firstParty = 0; + // First create the folder if it's missing, so users are never left wondering where updates are supposed to be put + if (!exists("../updates")) + create_directory("../updates"); if (exists("../updates/Edition")) { firstParty = 1; @@ -978,18 +984,19 @@ int GetUpdateStatus(Install_info_cfg *cu fstream file; file.open((install_iter->path().string() + "/Mod_Info.cfg").c_str()); if (!file.fail()) - ModPackage updatePackage = fileToModPackage(file, install_iter->path().filename()); + updatePackage = fileToModPackage(file, install_iter->path().filename()); else { file.close(); continue; } - if (exists("packages" + install_iter->path().filename() + "/Mod_Info.cfg")) + if (exists("packages/" + install_iter->path().filename() + "/Mod_Info.cfg")) { file.close(); - file.open(("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); + file.clear(); + file.open(("packages/" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); if (!file.fail()) - ModPackage installedPackage = fileToModPackage(file, install_iter->path().filename()); + installedPackage = fileToModPackage(file, install_iter->path().filename()); file.close(); if (updatePackage.modStringVersion > installedPackage.modStringVersion) { @@ -1004,27 +1011,6 @@ int GetUpdateStatus(Install_info_cfg *cu } } } - else - { - file.close(); - continue; - } - file.close(); - - file.open( ("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); - if (!file.fail()) - { - ModPackage installedPackage = fileToModPackage(file, install_iter->path().filename()); - } - else - { - file.close(); - return UPDATE_THIRD_PARTY; - } - file.close(); - if(((string)INSTALLER_VERSION).compare(updatePackage.installerVersion) < 1 && updatePackage.modStringVersion > installedPackage.modStringVersion) { - return UPDATE_THIRD_PARTY; - } } } catch (exception & ex) { @@ -1044,7 +1030,7 @@ bool ReadInstallInfoCfg(fstream *fileHan string strDaodanVersion = "Daodan_Version"; string strOniSplitVersion = "OniSplit_Version"; string strGUIWinVersion = "GUI_Win_Version"; - string strGUIMacVersion = "GUI_Mac_Version"; + string strGUIMacVersion = "GUI_Mac_Version"; string strReglobalize = "Reglobalize"; string strDeleteList = "Delete_List"; string strArrow = "->"; @@ -1286,81 +1272,9 @@ bool ProcessInstallerUpdate(Install_info return true; // returning 'true' tells the Installer to quit itself ASAP so it can be replaced by the process that is now running } - -void CrawlPackages(string pathToUpdate, string strPathToPackages) { - try{ - directory_iterator end; - for ( directory_iterator update_iter( pathToUpdate ); - update_iter != end; - ++update_iter ) - { - - ModPackage installedPackage, updatePackage; - string updateStr = update_iter->path().string() + "/Mod_Info.cfg"; - if ( !boost::iequals(update_iter->path().filename(),"Edition") - && !boost::iequals(update_iter->path().filename(),"Edition-patch") - && is_directory( update_iter->path() ) - && exists( update_iter->path().string() + "/Mod_Info.cfg" ) ) - { - bool update = 0; - fstream file; - file.open( (update_iter->path().string() + "/Mod_Info.cfg").c_str()); - if (!file.fail()) - { - updatePackage = fileToModPackage(file, update_iter->path().filename()); - } - else - { - file.close(); - continue; - } - file.close(); - file.clear(); - if(exists(strPathToPackages + "/" + update_iter->path().filename() + "/Mod_Info.cfg")) - { - file.open((strPathToPackages + "/" + update_iter->path().filename() + "/Mod_Info.cfg").c_str()); - if (!file.fail()) - { - installedPackage = fileToModPackage(file, update_iter->path().filename()); - file.close(); - if(updatePackage.modStringVersion > installedPackage.modStringVersion) { - update = 1; - } - } - else - { - file.close(); - update = 1; - } - file.close(); - } - else update = 1; - if(update) { - if(exists((path)(strPathToPackages + "/" + updatePackage.modStringName))) - remove_all((path)(strPathToPackages + "/" + updatePackage.modStringName)); - rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); - - } - } - } - } - catch (exception & ex) { - // ex.what(); - setStatusArea("Warning, handled exception: " + (string)ex.what()); - } -} - - -bool ProcessThirdPartyUpdates() { -CrawlPackages( "../updates", "./packages"); -return true; - // globalPackages = getPackages(); -// refreshMods(globalInstalledMods); -} - - bool ProcessAEUpdate(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) { + try { fstream file; string line; vector tokens, updateStarted; @@ -1380,12 +1294,13 @@ bool ProcessAEUpdate(Install_info_cfg *c string strOniApp = "Oni.exe"; #else string strOniApp = "Oni.app"; -#endif bool needNewTrashDir = false; +#endif + bool readingVerAndDate = false; #ifdef WIN32 - string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted + //string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted #else FILE *fUserName = NULL; char chrUserName[32]; @@ -1420,6 +1335,7 @@ bool ProcessAEUpdate(Install_info_cfg *c if (readingVerAndDate && tokens.capacity() >= 3) tokenize(tokens[2], updateStarted, "-"); } +#ifndef WIN32 if (updateStarted.capacity() < 3) needNewTrashDir = true; else @@ -1429,6 +1345,7 @@ bool ProcessAEUpdate(Install_info_cfg *c if (!exists(strTrashDir)) needNewTrashDir = true; } +#endif } #ifndef WIN32 if (!*installerJustUpdated || needNewTrashDir) // prepare a new directory for deleted files to go to @@ -1446,7 +1363,11 @@ bool ProcessAEUpdate(Install_info_cfg *c if (exists(strPathToEUFN + strOniApp)) { if (exists(strOniApp)) +#ifdef WIN32 + remove((path)strOniApp); +#else rename((path)strOniApp, (path)(strTrashDir + strOniApp)); +#endif rename((path)(strPathToEUFN + strOniApp), (path)strOniApp); } if (updateAE->OniSplitVersion.compare(currentAE->OniSplitVersion) >= 1) @@ -1454,7 +1375,11 @@ bool ProcessAEUpdate(Install_info_cfg *c if (exists(strPathToEUFNInstall + strOniSplit)) { if (exists(strOniSplit)) +#ifdef WIN32 + remove((path)strOniSplit); +#else rename((path)strOniSplit, (path)(strTrashDir + strOniSplit)); +#endif rename((path)(strPathToEUFNInstall + strOniSplit), (path)strOniSplit); } } @@ -1464,7 +1389,7 @@ bool ProcessAEUpdate(Install_info_cfg *c if (exists(strPathToEUFN + strDaodan)) { if (exists(("../" + strDaodan))) - rename((path)("../" + strDaodan), (path)(strTrashDir + strDaodan)); + remove((path)("../" + strDaodan)); rename((path)(strPathToEUFN + strDaodan), (path)("../" + strDaodan)); } } @@ -1473,9 +1398,9 @@ bool ProcessAEUpdate(Install_info_cfg *c if (exists(strPathToEUFNInstall + strWinGUI)) { if (exists((path)strWinGUI)) - rename((path)strWinGUI, (path)(strTrashDir + strWinGUI)); + remove((path)strWinGUI); if (exists(strWinGUILang)) - rename((path)strWinGUILang, (path)(strTrashDir + strWinGUILang)); + remove((path)strWinGUILang); rename((path)(strPathToEUFNInstall + strWinGUI), (path)strWinGUI); rename((path)(strPathToEUFNInstall + strWinGUILang), (path)strWinGUILang); } @@ -1508,8 +1433,10 @@ bool ProcessAEUpdate(Install_info_cfg *c while (curPos != string::npos && curPos < thePath.size()) { aParentPath = aParentPath + thePath.substr(lastPos, curPos - lastPos); +#ifndef WIN32 if (!exists(strTrashDir + aParentPath)) create_directory(strTrashDir + aParentPath); +#endif lastPos = curPos + 1; curPos = thePath.find("/", lastPos); aParentPath = aParentPath + "/"; @@ -1554,14 +1481,21 @@ bool ProcessAEUpdate(Install_info_cfg *c for (vector::iterator iter = filesToMove.begin(); iter != filesToMove.end(); iter++) { if (exists(strPathToPackages + strGlobalize + *iter)) +#ifdef WIN32 + remove((path)(strPathToPackages + strGlobalize + *iter)); +#else rename((path)(strPathToPackages + strGlobalize + *iter), (path)(strTrashDir + *iter)); +#endif rename((path)(strPathToEUFNPackages + strGlobalize + *iter), (path)(strPathToPackages + strGlobalize + *iter)); } // Clean up after ourselves, trashing any packages or programs in the update package that are not newer than the current AE +#ifdef WIN32 + remove((path)strPathToEUFN); +#else create_directory(strTrashDir + "Unneeded update files"); rename((path)strPathToEUFN, (path)(strTrashDir + "Unneeded update files/" + strEUFN)); - +#endif // Write to log that we are finished with update ptime end_time(second_clock::local_time()); string progressMsg2 = "Edition was updated to:\n" + @@ -1579,9 +1513,16 @@ bool ProcessAEUpdate(Install_info_cfg *c CheckForGlobalization(true); // the 'true' value forces re-globalization globalPackages = getPackages(); // refresh the list in memory - // TODO: Refresh the packages list in the window - + wxCommandEvent e; + TheWindow->OnRefreshButtonClick( e ); return true; + } + catch (exception & ex) + { + setStatusArea("Warning, handled exception: " + (string)ex.what()); + return false; + } + } void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages) @@ -1634,32 +1575,31 @@ void ProcessPackageUpdates(string pathTo if (!file.fail()) { installedPackage = fileToModPackage(file, updtFolder); - file.close(); - if (updatePackage.modStringVersion > installedPackage.modStringVersion) - { - if (updatePackage.installerVersion <= INSTALLER_VERSION) - { + } + file.close(); + } + file.close(); + if (updatePackage.modStringVersion > installedPackage.modStringVersion) + { + if (updatePackage.installerVersion <= INSTALLER_VERSION) + { + if(exists(strPathToPackages + "/" + updatePackage.modStringName)) { #ifdef WIN32 - remove_all((path)(strPathToPackages + "/" + installedPackage.modStringName)); + remove_all((path)(strPathToPackages + "/" + updatePackage.modStringName)); #else - if (needNewTrashDir) - { - strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast(tmStartTime.tm_hour) + "-" + - boost::lexical_cast(tmStartTime.tm_min) + "-" + boost::lexical_cast(tmStartTime.tm_sec) + "/"; - create_directory(strTrashDir); - needNewTrashDir = false; - } - rename((path)(strPathToPackages + "/" + installedPackage.modStringName), (path)(strTrashDir + installedPackage.modStringName)); -#endif - rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); + if (needNewTrashDir) + { + strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast(tmStartTime.tm_hour) + "-" + + boost::lexical_cast(tmStartTime.tm_min) + "-" + boost::lexical_cast(tmStartTime.tm_sec) + "/"; + create_directory(strTrashDir); + needNewTrashDir = false; } + rename((path)(strPathToPackages + "/" + updatePackage.modStringName), (path)(strTrashDir + updatePackage.modStringName)); +#endif } + rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); } - else - file.close(); } - file.close(); - file.clear(); } } } @@ -1667,6 +1607,8 @@ void ProcessPackageUpdates(string pathTo { setStatusArea("Warning, handled exception: " + (string)ex.what()); } + wxCommandEvent e; + TheWindow->OnRefreshButtonClick( e ); } /* MakePathLocalToGlobalize is a function used once by ProcessAEUpdate() that takes a file in an \