Changeset 506 for AE/Installer/trunk/source
- Timestamp:
- Apr 5, 2010, 4:11:45 AM (15 years ago)
- Location:
- AE/Installer/trunk/source
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/Installer/trunk/source/aeinstallerapp.cpp
r504 r506 115 115 if (updateStatus) // updateStatus was set when MainWindow::CreateControls() was called during initialization of the window 116 116 { 117 string updateMsg = "An update for the Anniversary Edition is available.\n" ; // for some reason we can't set the initial value while using the '+' operator...118 updateMsg = updateMsg + "Do you wish to update to Edition version " + updateAE.AEVersion + "?\n" +119 117 string updateMsg = "An update for the Anniversary Edition is available.\n" 118 "Do you wish to update to Edition version " + updateAE.AEVersion + "?\n" 119 "(Current version is " + currentAE.AEVersion + ")\n"; // ...so we tack the rest on in a second command 120 120 wxMessageDialog* updateNotification; 121 121 … … 140 140 ProcessAEUpdate(¤tAE, &updateAE, &installerJustUpdated); 141 141 break; 142 case UPDATE_ THIRD_PARTY: // there's an update with no globalization or Installer strings attached142 case UPDATE_PKG_AVAIL: // there's an update with no globalization or Installer strings attached 143 143 updateMsg = (string)"One or more third party update(s) for Anniversary Edition package(s) are available.\n" + 144 144 (string)"Please note that the AE team assumes no responsibility for the content of third party mods" + … … 147 147 updateNotification = new wxMessageDialog(TheWindow, updateMsg.c_str(), "AE Installer Alert", wxYES_NO | wxICON_EXCLAMATION, wxDefaultPosition); 148 148 if (updateNotification->ShowModal() == wxID_YES) 149 Process ThirdPartyUpdates();149 ProcessPackageUpdates("../updates", "./packages"); 150 150 break; 151 151 case UPDATE_GLOB_AVAIL: // there's an update with globalization strings attached -
AE/Installer/trunk/source/globals.h
r504 r506 41 41 42 42 //#pragma mark DEFINES 43 #define INSTALLER_VERSION "1. 2" // only place we need to change this43 #define INSTALLER_VERSION "1.1" // only place we need to change this 44 44 #define UPDATE_LOG_READ_ERR -1 45 45 #define UPDATE_INST_REPL_ERR -2 … … 50 50 #define UPDATE_INST_AVAIL 3 51 51 #define UPDATE_CONT_UPD 4 52 #define UPDATE_ THIRD_PARTY552 #define UPDATE_PKG_AVAIL 5 53 53 //#pragma mark STRUCTS 54 54 struct ModPackage … … 99 99 bool ProcessInstallerUpdate(Install_info_cfg *, Install_info_cfg *); 100 100 bool ProcessAEUpdate(Install_info_cfg *, Install_info_cfg *, bool *); 101 bool ProcessThirdPartyUpdates(void);101 void ProcessPackageUpdates(string, string); 102 102 void callRefreshMods(void); 103 103 string escapePath(string input); -
AE/Installer/trunk/source/installer.cpp
r505 r506 232 232 233 233 if ( strcmp(levels[i].c_str(), "0") ){ 234 system((strOniSplit + " -move:overwrite ../GameDataFolder/level" + levels[i] + "_Final ../GameDataFolder/level" + levels[i] + "_Final/AKEV/AKEV*.oni").c_str()); 234 system((strOniSplit + " -move:overwrite ../GameDataFolder/level" + levels[i] + "_Final ../GameDataFolder/level" + levels[i] + 235 "_Final/AKEV/AKEV*.oni").c_str()); 235 236 remove( "../GameDataFolder/level" + levels[i] + "_Final/AKEV" ); 236 237 } … … 246 247 { 247 248 logfile << "\tReimporting level" << levels[i] << "_Final.oni\n"; 248 setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + levels[i]+"_Final.oni"); 249 setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + 250 levels[i] + "_Final.oni"); 249 251 logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" 250 252 + levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str() << '\n'; … … 307 309 Tests for presence of prefs with [ -f ] before doing anything so it doesn't create a partial prefs file -- just in case user has never 308 310 run Oni before :-p */ 309 string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for Edition/ (Oni wants thefolder that *contains* the GDF)311 string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for Edition/ (Oni wants folder that *contains* the GDF) 310 312 //bad Iritscen, bad! fixed buffers can cause crashes. 311 313 /*char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '"; … … 375 377 376 378 ModPackage fileToModPackage(fstream &file, string modName) 377 { 378 /* 379 This converts a file to a ModPackage struct. 380 381 A few notes... 382 "iter" is the current word we are on. I should have named it "token" or something, but I don't have multiple iterators, so its ok. 383 I refer to (*iter) at the beginning of each if statement block. I could probably store it as a variable, but I'm pretty sure that dereferencing a pointer\iterator isn't much 384 slower than reading a variable. 385 */ 386 379 { 387 380 ModPackage package; 388 381 string line; … … 576 569 577 570 setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats 578 setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); 571 setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + 572 dir_itr->path().filename() + " "); 579 573 580 574 system(importCommand.c_str()); … … 632 626 633 627 setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats 634 setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); 628 setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + 629 dir_itr->path().filename() + " "); 635 630 system(importCommand.c_str()); 636 631 j++; … … 709 704 void copyBSL(string copypath, vector<string>& BSLfolders, ModPackage pkg) 710 705 { 711 ofstream BSLlog("BSL 2.log", ios::app );706 ofstream BSLlog("BSL.log", ios::app ); 712 707 713 708 try { … … 817 812 | launches, this function will be called again but will | 818 813 | return UPDATE_SIMP_AVAIL or UPDATE_GLOB_AVAIL) | 814 | UPDATE_PKG_AVAIL -- A newer version of individual package(s) is available | 819 815 \* UPDATE_CONT_UPD -- Currently unused */ 820 816 int GetUpdateStatus(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) … … 931 927 newUpdateLog << "Installer was updated to:\n"; 932 928 newUpdateLog << newUpdateLine.c_str(); 933 *installerJustUpdated = true; // this value is indirectly returned to AEInstallerAp ::OnInit()929 *installerJustUpdated = true; // this value is indirectly returned to AEInstallerApp::OnInit() 934 930 doneReadingFile = true; 935 931 newUpdateLog.close(); … … 970 966 } 971 967 } 972 try { 973 directory_iterator end; 974 if(exists("../updates")){ 975 for ( directory_iterator install_iter( "../updates" ); 976 install_iter != end; 977 ++install_iter ) 978 { 979 980 ModPackage installedPackage, updatePackage; 981 if ( is_directory( install_iter->path() ) && exists( install_iter->path().string() + "/Mod_Info.cfg" ) ) { 982 fstream file; 983 file.open( (install_iter->path().string() + "/Mod_Info.cfg").c_str()); 984 if (!file.fail()) 985 { 986 ModPackage updatePackage = fileToModPackage(file, install_iter->path().filename()); 987 } 988 else 989 { 990 file.close(); 991 continue; 992 } 993 if(!exists("packages" + install_iter->path().filename() + "/Mod_Info.cfg")); 994 file.close(); 995 file.open( ("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); 996 if (!file.fail()) 997 { 998 ModPackage installedPackage = fileToModPackage(file, install_iter->path().filename()); 999 } 1000 else 1001 { 1002 file.close(); 1003 return UPDATE_THIRD_PARTY; 1004 } 1005 file.close(); 1006 if(updatePackage.modStringVersion > installedPackage.modStringVersion) { 1007 return UPDATE_THIRD_PARTY; 1008 } 1009 1010 } 1011 } 1012 1013 } 968 try 969 { 970 directory_iterator end; 971 if (exists("../updates")) 972 { 973 for (directory_iterator install_iter("../updates"); install_iter != end; ++install_iter) 974 { 975 ModPackage installedPackage, updatePackage; 976 if (is_directory(install_iter->path()) && exists(install_iter->path().string() + "/Mod_Info.cfg")) 977 { 978 fstream file; 979 file.open((install_iter->path().string() + "/Mod_Info.cfg").c_str()); 980 if (!file.fail()) 981 ModPackage updatePackage = fileToModPackage(file, install_iter->path().filename()); 982 else 983 { 984 file.close(); 985 continue; 986 } 987 if (exists("packages" + install_iter->path().filename() + "/Mod_Info.cfg")) 988 { 989 file.close(); 990 file.open(("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); 991 if (!file.fail()) 992 ModPackage installedPackage = fileToModPackage(file, install_iter->path().filename()); 993 file.close(); 994 if (updatePackage.modStringVersion > installedPackage.modStringVersion) 995 { 996 if (updatePackage.installerVersion <= INSTALLER_VERSION) 997 return UPDATE_PKG_AVAIL; 998 } 999 } 1000 else 1001 { 1002 file.close(); 1003 return UPDATE_PKG_AVAIL; 1004 } 1005 } 1006 } 1007 } 1014 1008 } 1015 1009 catch (exception & ex) { 1016 1010 // setStatusArea("Warning, handled exception: " + (string)ex.what()); 1017 1011 } 1018 1019 1012 1020 1013 return UPDATE_NO_UPD_AVAIL; … … 1243 1236 string popenCommand = "../updates/" + strEUFN + "/install/"; 1244 1237 #ifdef WIN32 1245 // TODO: Fill in Windows equivalent of code below :-31246 1238 popenCommand = "replace_installer.bat"; 1247 1239 #else … … 1273 1265 return true; // returning 'true' tells the Installer to quit itself ASAP so it can be replaced by the process that is now running 1274 1266 } 1275 //strPathToEUFNPackages1276 1277 void CrawlPackages(string pathToUpdate, string strPathToPackages) {1278 try{1279 directory_iterator end;1280 for ( directory_iterator update_iter( pathToUpdate );1281 update_iter != end;1282 ++update_iter )1283 {1284 1285 ModPackage installedPackage, updatePackage;1286 string updateStr = update_iter->path().string() + "/Mod_Info.cfg";1287 if ( !boost::iequals(update_iter->path().filename(),"Edition")1288 && !boost::iequals(update_iter->path().filename(),"Edition-patch")1289 && is_directory( update_iter->path() )1290 && exists( update_iter->path().string() + "/Mod_Info.cfg" ) )1291 {1292 bool update = 0;1293 fstream file;1294 file.open( (update_iter->path().string() + "/Mod_Info.cfg").c_str());1295 if (!file.fail())1296 {1297 updatePackage = fileToModPackage(file, update_iter->path().filename());1298 }1299 else1300 {1301 file.close();1302 continue;1303 }1304 if(!exists(strPathToPackages + "/" + update_iter->path().filename() + "/Mod_Info.cfg"));1305 file.close();1306 file.clear();1307 file.open((strPathToPackages + "/" + update_iter->path().filename() + "/Mod_Info.cfg").c_str());1308 if (!file.fail())1309 {1310 installedPackage = fileToModPackage(file, update_iter->path().filename());1311 file.close();1312 if(updatePackage.modStringVersion > installedPackage.modStringVersion) {1313 remove_all((path)(strPathToPackages + "/" + installedPackage.modStringName));1314 update = 1;1315 }1316 }1317 else1318 {1319 file.close();1320 update = 1;1321 }1322 file.close();1323 1324 if(update) {1325 rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName));1326 1327 }1328 }1329 }1330 }1331 catch (exception & ex) {1332 // ex.what();1333 setStatusArea("Warning, handled exception: " + (string)ex.what());1334 }1335 }1336 1337 1338 bool ProcessThirdPartyUpdates() {1339 CrawlPackages( "../updates", "./packages");1340 return true;1341 // globalPackages = getPackages();1342 // refreshMods(globalInstalledMods);1343 }1344 1345 1267 1346 1268 bool ProcessAEUpdate(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) … … 1369 1291 bool readingVerAndDate = false; 1370 1292 1371 // TODO: Fill in Windows equivalent of code below1372 1293 #ifdef WIN32 1373 string strTrashDir = "Trash\\"; 1294 string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted 1374 1295 #else 1375 1296 FILE *fUserName = NULL; … … 1508 1429 } 1509 1430 1510 CrawlPackages( strPathToEUFNPackages,strPathToPackages);1431 ProcessPackageUpdates(strPathToEUFNPackages, strPathToPackages); 1511 1432 1512 1433 // Next, we get a list of which files and folders in the update's Globalize folder to move over; all files not starting with '.' will be moved... … … 1568 1489 1569 1490 return true; 1491 } 1492 1493 void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages) 1494 { 1495 ptime startTime(second_clock::local_time()); 1496 #ifdef WIN32 1497 string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted 1498 #else 1499 FILE *fUserName = NULL; 1500 char chrUserName[32]; 1501 fUserName = popen("whoami", "r"); 1502 fgets(chrUserName, sizeof(chrUserName), fUserName); 1503 pclose(fUserName); 1504 string strUserName = (string)chrUserName; // stringsblaaarrrgggghhhh 1505 int endOfName = strUserName.find("\n", 0); 1506 string strTrashDir = "/Users/" + strUserName.substr(0, endOfName) + "/.Trash/"; 1507 bool needNewTrashDir = true; 1508 tm tmStartTime = to_tm(startTime); 1509 #endif 1510 1511 try 1512 { 1513 directory_iterator end; 1514 for (directory_iterator update_iter(pathToUpdate); update_iter != end; ++update_iter) 1515 { 1516 ModPackage installedPackage, updatePackage; 1517 string updtPath = update_iter->path().string(); 1518 string updtFolder = update_iter->path().filename(); 1519 string updtModInfo = updtPath + "/Mod_Info.cfg"; 1520 string instModInfo = strPathToPackages + "/" + updtFolder + "/Mod_Info.cfg"; 1521 if (!boost::iequals(updtFolder, "Edition") 1522 && !boost::iequals(updtFolder, "Edition-patch") 1523 && is_directory(update_iter->path()) 1524 && exists(updtModInfo)) 1525 { 1526 fstream file; 1527 file.open((updtModInfo).c_str()); 1528 if (!file.fail()) 1529 updatePackage = fileToModPackage(file, updtFolder); 1530 else 1531 { 1532 file.close(); 1533 continue; 1534 } 1535 if (exists(instModInfo)) 1536 { 1537 file.close(); 1538 file.clear(); 1539 file.open(instModInfo.c_str()); 1540 if (!file.fail()) 1541 { 1542 installedPackage = fileToModPackage(file, updtFolder); 1543 file.close(); 1544 if (updatePackage.modStringVersion > installedPackage.modStringVersion) 1545 { 1546 if (updatePackage.installerVersion <= INSTALLER_VERSION) 1547 { 1548 #ifdef WIN32 1549 remove_all((path)(strPathToPackages + "/" + installedPackage.modStringName)); 1550 #else 1551 if (needNewTrashDir) 1552 { 1553 strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast<string>(tmStartTime.tm_hour) + "-" + 1554 boost::lexical_cast<string>(tmStartTime.tm_min) + "-" + boost::lexical_cast<string>(tmStartTime.tm_sec) + "/"; 1555 create_directory(strTrashDir); 1556 needNewTrashDir = false; 1557 } 1558 rename((path)(strPathToPackages + "/" + installedPackage.modStringName), (path)(strTrashDir + installedPackage.modStringName)); 1559 #endif 1560 rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); 1561 } 1562 } 1563 } 1564 else 1565 file.close(); 1566 } 1567 file.close(); 1568 file.clear(); 1569 } 1570 } 1571 } 1572 catch (exception & ex) 1573 { 1574 setStatusArea("Warning, handled exception: " + (string)ex.what()); 1575 } 1570 1576 } 1571 1577
Note:
See TracChangeset
for help on using the changeset viewer.