ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/AE/Installer/trunk/source/installer.cpp
(Generate patch)

Comparing AE/Installer/trunk/source/installer.cpp (file contents):
Revision 507 by gumby, Sat Apr 24 17:41:46 2010 UTC vs.
Revision 542 by iritscen, Mon May 24 02:43:35 2010 UTC

# Line 27 | Line 27 | using namespace boost::posix_time;
27   // externs declared in installer.h
28   string strInstallCfg = "../GameDataFolder/Add.cfg";
29   string strEUFN = "Edition"; // GetUpdateStatus() may set this to "Edition-patch" later, but this is the assumed name of the new Edition folder in Updates/
30 + extern MainWindow* TheWindow;
31  
32   int globalizeData(void)
33   {
# Line 734 | Line 735 | void copyBSL(string copypath, vector<str
735                                                          copy_file(bsl_itr->path(),  "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename());
736                                                  }
737                                          }
738 <                                        BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon
739 <                                        BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ;
738 >                                        if( !pkg.hasAddon ) {
739 >                                                BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon
740 >                                                BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ;
741 >                                        }
742                                  }
743                          }
744                  }
# Line 841 | Line 844 | int GetUpdateStatus(Install_info_cfg *cu
844                          return UPDATE_LOG_READ_ERR;
845          }
846  
847 <        // Is there an update folder, and is it a monthly release or a patch?
847 >        // Is there an update in the updates/ folder, and is it a monthly release or a patch?
848          bool firstParty = 0;
849 +        // First create the folder if it's missing, so users are never left wondering where updates are supposed to be put
850 +        if (!exists("../updates"))
851 +                create_directory("../updates");
852          if (exists("../updates/Edition"))
853          {
854                  firstParty = 1;
# Line 978 | Line 984 | int GetUpdateStatus(Install_info_cfg *cu
984                                          fstream file;
985                                          file.open((install_iter->path().string() + "/Mod_Info.cfg").c_str());
986                                          if (!file.fail())
987 <                                                ModPackage updatePackage = fileToModPackage(file, install_iter->path().filename());
987 >                                                updatePackage = fileToModPackage(file, install_iter->path().filename());
988                                          else
989                                          {
990                                                  file.close();
991                                                  continue;
992                                          }
993 <                                        if (exists("packages" + install_iter->path().filename() + "/Mod_Info.cfg"))
993 >                                        if (exists("packages/" + install_iter->path().filename() + "/Mod_Info.cfg"))
994                                          {
995                                                  file.close();
996 <                                                file.open(("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str());
996 >                                                file.clear();
997 >                                                file.open(("packages/" + install_iter->path().filename() + "/Mod_Info.cfg").c_str());
998                                                  if (!file.fail())
999 <                                                        ModPackage installedPackage = fileToModPackage(file, install_iter->path().filename());
999 >                                                        installedPackage = fileToModPackage(file, install_iter->path().filename());
1000                                                  file.close();
1001                                                  if (updatePackage.modStringVersion > installedPackage.modStringVersion)
1002                                                  {
# Line 1004 | Line 1011 | int GetUpdateStatus(Install_info_cfg *cu
1011                                          }
1012                                  }
1013                          }
1007                        else
1008                        {
1009                                file.close();
1010                                continue;
1011                        }
1012                        file.close();
1013                                                
1014                        file.open( ("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str());
1015                        if (!file.fail())
1016                        {
1017                                ModPackage installedPackage = fileToModPackage(file, install_iter->path().filename());
1018                        }
1019                        else
1020                        {
1021                                file.close();
1022                                return UPDATE_THIRD_PARTY;
1023                        }
1024                        file.close();
1025                        if(((string)INSTALLER_VERSION).compare(updatePackage.installerVersion) < 1 && updatePackage.modStringVersion > installedPackage.modStringVersion) {
1026                                return UPDATE_THIRD_PARTY;
1027                        }
1014                  }
1015          }
1016          catch (exception & ex) {
# Line 1044 | Line 1030 | bool ReadInstallInfoCfg(fstream *fileHan
1030          string strDaodanVersion = "Daodan_Version";
1031          string strOniSplitVersion = "OniSplit_Version";
1032          string strGUIWinVersion = "GUI_Win_Version";
1033 <        string strGUIMacVersion = "GUI_Mac_Version";
1033 >        string strGUIMacVersion = "GUI_Mac_Version";
1034          string strReglobalize = "Reglobalize";
1035          string strDeleteList = "Delete_List";
1036          string strArrow = "->";
# Line 1286 | Line 1272 | bool ProcessInstallerUpdate(Install_info
1272          return true; // returning 'true' tells the Installer to quit itself ASAP so it can be replaced by the process that is now running
1273   }
1274  
1289
1290 void CrawlPackages(string pathToUpdate, string strPathToPackages) {
1291        try{
1292                directory_iterator end;
1293                for ( directory_iterator update_iter( pathToUpdate );
1294                        update_iter != end;
1295                        ++update_iter )
1296                {
1297
1298                        ModPackage installedPackage, updatePackage;
1299                        string updateStr = update_iter->path().string() + "/Mod_Info.cfg";
1300                        if ( !boost::iequals(update_iter->path().filename(),"Edition")
1301                                && !boost::iequals(update_iter->path().filename(),"Edition-patch")
1302                                && is_directory( update_iter->path() )
1303                                && exists( update_iter->path().string() + "/Mod_Info.cfg" ) )
1304                        {
1305                                bool update = 0;
1306                                fstream file;
1307                                file.open( (update_iter->path().string() + "/Mod_Info.cfg").c_str());  
1308                                if (!file.fail())
1309                                {
1310                                        updatePackage = fileToModPackage(file, update_iter->path().filename());
1311                                }
1312                                else
1313                                {
1314                                        file.close();
1315                                        continue;
1316                                }
1317                                file.close();
1318                                file.clear();
1319                                if(exists(strPathToPackages + "/" + update_iter->path().filename() + "/Mod_Info.cfg"))
1320                                {
1321                                file.open((strPathToPackages + "/" + update_iter->path().filename() + "/Mod_Info.cfg").c_str());
1322                                if (!file.fail())
1323                                {
1324                                        installedPackage = fileToModPackage(file, update_iter->path().filename());
1325                                        file.close();
1326                                        if(updatePackage.modStringVersion > installedPackage.modStringVersion) {
1327                                                update = 1;
1328                                        }
1329                                }
1330                                else
1331                                {
1332                                        file.close();
1333                                        update = 1;
1334                                }
1335                                file.close();
1336                                }
1337                                else update = 1;
1338                                if(update) {
1339                                        if(exists((path)(strPathToPackages +  "/" + updatePackage.modStringName)))
1340                                                remove_all((path)(strPathToPackages +  "/" + updatePackage.modStringName));                    
1341                                        rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName));
1342
1343                                }
1344                        }
1345                }
1346        }
1347        catch (exception & ex) {
1348                //      ex.what();
1349                setStatusArea("Warning, handled exception: " + (string)ex.what());
1350        }
1351 }
1352
1353
1354 bool ProcessThirdPartyUpdates() {
1355 CrawlPackages( "../updates",  "./packages");
1356 return true;
1357        //      globalPackages = getPackages();
1358 //      refreshMods(globalInstalledMods);
1359 }
1360
1361
1275   bool ProcessAEUpdate(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated)
1276   {
1277          fstream file;
# Line 1579 | Line 1492 | bool ProcessAEUpdate(Install_info_cfg *c
1492                  CheckForGlobalization(true); // the 'true' value forces re-globalization
1493          
1494          globalPackages = getPackages(); // refresh the list in memory
1495 <        // TODO: Refresh the packages list in the window
1496 <
1495 >        wxCommandEvent e;
1496 >        TheWindow->OnRefreshButtonClick( e );
1497          return true;
1498   }
1499  
# Line 1634 | Line 1547 | void ProcessPackageUpdates(string pathTo
1547                                          if (!file.fail())
1548                                          {
1549                                                  installedPackage = fileToModPackage(file, updtFolder);
1550 <                                                file.close();
1551 <                                                if (updatePackage.modStringVersion > installedPackage.modStringVersion)
1552 <                                                {
1553 <                                                        if (updatePackage.installerVersion <= INSTALLER_VERSION)
1554 <                                                        {
1550 >                                        }
1551 >                                        file.close();
1552 >                                }
1553 >                                file.close();
1554 >                                if (updatePackage.modStringVersion > installedPackage.modStringVersion)
1555 >                                {
1556 >                                        if (updatePackage.installerVersion <= INSTALLER_VERSION)
1557 >                                        {
1558 >                                                if(exists(strPathToPackages +  "/" + updatePackage.modStringName)) {
1559   #ifdef WIN32
1560 <                                                                remove_all((path)(strPathToPackages +  "/" + installedPackage.modStringName));
1560 >                                                        remove_all((path)(strPathToPackages +  "/" + updatePackage.modStringName));
1561   #else
1562 <                                                                if (needNewTrashDir)
1563 <                                                                {
1564 <                                                                        strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast<string>(tmStartTime.tm_hour) + "-" +
1565 <                                                                                                  boost::lexical_cast<string>(tmStartTime.tm_min) + "-" + boost::lexical_cast<string>(tmStartTime.tm_sec) + "/";
1566 <                                                                        create_directory(strTrashDir);
1567 <                                                                        needNewTrashDir = false;
1651 <                                                                }
1652 <                                                                rename((path)(strPathToPackages +  "/" + installedPackage.modStringName), (path)(strTrashDir + installedPackage.modStringName));
1653 < #endif
1654 <                                                                rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName));
1562 >                                                        if (needNewTrashDir)
1563 >                                                        {
1564 >                                                                strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast<string>(tmStartTime.tm_hour) + "-" +
1565 >                                                                        boost::lexical_cast<string>(tmStartTime.tm_min) + "-" + boost::lexical_cast<string>(tmStartTime.tm_sec) + "/";
1566 >                                                                create_directory(strTrashDir);
1567 >                                                                needNewTrashDir = false;
1568                                                          }
1569 +                                                        rename((path)(strPathToPackages +  "/" + updatePackage.modStringName), (path)(strTrashDir + updatePackage.modStringName));
1570 + #endif
1571                                                  }
1572 +                                                rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName));
1573                                          }
1658                                        else
1659                                                file.close();
1574                                  }
1661                                file.close();
1662                                file.clear();
1575                          }
1576                  }
1577          }
# Line 1667 | Line 1579 | void ProcessPackageUpdates(string pathTo
1579          {
1580                  setStatusArea("Warning, handled exception: " + (string)ex.what());
1581          }
1582 +        wxCommandEvent e;
1583 +        TheWindow->OnRefreshButtonClick( e );
1584   }
1585  
1586   /* MakePathLocalToGlobalize is a function used once by ProcessAEUpdate() that takes a file in an        \

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)