| 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 |
|
{ |
| 597 |
|
else if(splitInstances == false){ |
| 598 |
|
directory_iterator end_iter; |
| 599 |
|
|
| 600 |
< |
for ( directory_iterator dir_itr( vanilla_dir ); |
| 601 |
< |
dir_itr != end_iter; |
| 602 |
< |
++dir_itr ) |
| 603 |
< |
{ |
| 604 |
< |
if ( is_directory( dir_itr->status() ) ) |
| 605 |
< |
{ |
| 606 |
< |
numberOfDats++; |
| 600 |
> |
|
| 601 |
> |
char levelnums[256] = {0}; |
| 602 |
> |
|
| 603 |
> |
|
| 604 |
> |
|
| 605 |
> |
for(int k = 0; k < 256; k++) { |
| 606 |
> |
if( exists( (path)("./VanillaDats/level" + lexical_cast<std::string>(k) + "_final/") ) ) { |
| 607 |
> |
levelnums[k] = 1; |
| 608 |
> |
|
| 609 |
|
} |
| 610 |
|
} |
| 611 |
< |
|
| 611 |
> |
|
| 612 |
> |
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 613 |
> |
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 614 |
> |
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 615 |
> |
for(int k = 0; k < 256; k++) { |
| 616 |
> |
if( globalPackages[j].hasOnis && |
| 617 |
> |
exists( (path)("packages/" + globalPackages[j].modStringName + "/oni/level" + lexical_cast<std::string>(k) + "_final/") ) ) { |
| 618 |
> |
levelnums[k] = 1; |
| 619 |
> |
|
| 620 |
> |
} |
| 621 |
> |
} |
| 622 |
> |
} |
| 623 |
> |
} |
| 624 |
> |
} |
| 625 |
> |
for (int levelnum = 0; levelnum < 256; levelnum++) |
| 626 |
> |
if (levelnums[levelnum]) |
| 627 |
> |
numberOfDats++; |
| 628 |
> |
|
| 629 |
|
out << numberOfDats; |
| 630 |
|
datString = out.str(); |
| 631 |
< |
|
| 632 |
< |
for ( directory_iterator dir_itr( vanilla_dir ); |
| 613 |
< |
dir_itr != end_iter; |
| 614 |
< |
++dir_itr ) |
| 615 |
< |
{ |
| 631 |
> |
|
| 632 |
> |
for(int levelnum = 0; levelnum < 256; levelnum++) { |
| 633 |
|
try |
| 634 |
|
{ |
| 635 |
< |
if ( is_directory( dir_itr->status() ) ) |
| 635 |
> |
if ( levelnums[levelnum] ) |
| 636 |
|
{ |
| 637 |
< |
importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " "; |
| 637 |
> |
importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + "level" + lexical_cast<std::string>(levelnum) + "_Final "; |
| 638 |
|
for (unsigned int i = 0; i < installedMods.size(); ++i) { |
| 639 |
< |
if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename() )) |
| 640 |
< |
importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename(); |
| 639 |
> |
if (exists((path)("packages/" + installedMods[i] + "/oni/level" + lexical_cast<std::string>(levelnum) + "_final") )) |
| 640 |
> |
importCommand += " packages/" + installedMods[i] + "/oni/level" + lexical_cast<std::string>(levelnum) + "_Final"; |
| 641 |
|
} |
| 642 |
< |
importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; |
| 642 |
> |
importCommand += " ../GameDataFolder/level" + lexical_cast<std::string>(levelnum) + "_Final.dat >> Install.log"; |
| 643 |
|
|
| 644 |
|
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
| 645 |
|
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
| 646 |
< |
dir_itr->path().filename() + " "); |
| 646 |
> |
"level" + lexical_cast<std::string>(levelnum) + "_Final"+ " "); |
| 647 |
|
system(importCommand.c_str()); |
| 648 |
|
j++; |
| 649 |
|
} |
| 663 |
|
vector<string> skippedfolders; |
| 664 |
|
|
| 665 |
|
ofstream BSLlog("BSL.log"); |
| 666 |
+ |
if(exists("../GameDataFolder/BSLBackup/")) { |
| 667 |
+ |
remove_all("../GameDataFolder/BSLBackup/"); |
| 668 |
+ |
} |
| 669 |
+ |
else { |
| 670 |
+ |
create_directory("../GameDataFolder/BSLBackup/"); |
| 671 |
+ |
} |
| 672 |
+ |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 673 |
|
for ( directory_iterator dir_itr( "../GameDataFolder/IGMD/" ), end_itr; |
| 674 |
|
dir_itr != end_itr; |
| 675 |
|
++dir_itr ) { |
| 682 |
|
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 683 |
|
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 684 |
|
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 685 |
< |
if(!(globalPackages[j].hasAddon || globalPackages[j].hasBSL)) break; //skip non-BSL |
| 685 |
> |
if(globalPackages[j].hasBSL) break; //skip non-BSL |
| 686 |
|
if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { |
| 687 |
|
copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); |
| 688 |
|
BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; |
| 691 |
|
} |
| 692 |
|
} |
| 693 |
|
|
| 694 |
+ |
|
| 695 |
+ |
|
| 696 |
|
ModPackage emptyPackage; |
| 697 |
|
emptyPackage.modStringName = "VanillaBSL"; |
| 698 |
|
emptyPackage.hasBSL = 1; |
| 699 |
|
copyBSL("packages/VanillaBSL/IGMD", BSLfolders, emptyPackage); |
| 700 |
|
BSLlog.close(); |
| 701 |
< |
|
| 701 |
> |
|
| 702 |
> |
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 703 |
> |
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 704 |
> |
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 705 |
> |
if(!globalPackages[j].hasAddon) break; //skip non-BSL |
| 706 |
> |
if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { |
| 707 |
> |
copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); |
| 708 |
> |
BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; |
| 709 |
> |
} |
| 710 |
> |
} |
| 711 |
> |
} |
| 712 |
> |
} |
| 713 |
> |
|
| 714 |
|
logfile << "Writing config file"; |
| 715 |
|
writeInstalledMods(installedMods); |
| 716 |
|
setProgressBar(1000); |
| 751 |
|
if ( is_directory( dir_itr->path() ) && dir_itr->path().string() != ".svn" ) { |
| 752 |
|
BSLlog << "Testing " << dir_itr->path().string() << " HasBSL: " << pkg.hasBSL << " HasAddon: " << pkg.hasAddon << "\n"; |
| 753 |
|
int skip_folder = 0; |
| 754 |
< |
|
| 755 |
< |
for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders |
| 756 |
< |
BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; |
| 757 |
< |
if(dir_itr->path().filename() == BSLfolders[k]) { |
| 758 |
< |
skip_folder = 1; |
| 759 |
< |
BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; |
| 760 |
< |
break; |
| 754 |
> |
if(!pkg.hasAddon) { |
| 755 |
> |
for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders |
| 756 |
> |
BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; |
| 757 |
> |
if(dir_itr->path().filename() == BSLfolders[k]) { |
| 758 |
> |
skip_folder = 1; |
| 759 |
> |
BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; |
| 760 |
> |
break; |
| 761 |
> |
} |
| 762 |
|
} |
| 763 |
|
} |
| 764 |
|
if (!skip_folder && !exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/ignore.txt")) { |
| 773 |
|
copy_file(bsl_itr->path(), "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 774 |
|
} |
| 775 |
|
} |
| 776 |
< |
BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon |
| 777 |
< |
BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; |
| 776 |
> |
if( !pkg.hasAddon ) { |
| 777 |
> |
BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon |
| 778 |
> |
BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; |
| 779 |
> |
} |
| 780 |
|
} |
| 781 |
|
} |
| 782 |
|
} |
| 882 |
|
return UPDATE_LOG_READ_ERR; |
| 883 |
|
} |
| 884 |
|
|
| 885 |
< |
// Is there an update folder, and is it a monthly release or a patch? |
| 885 |
> |
// Is there an update in the updates/ folder, and is it a monthly release or a patch? |
| 886 |
|
bool firstParty = 0; |
| 887 |
+ |
// First create the folder if it's missing, so users are never left wondering where updates are supposed to be put |
| 888 |
+ |
if (!exists("../updates")) |
| 889 |
+ |
create_directory("../updates"); |
| 890 |
|
if (exists("../updates/Edition")) |
| 891 |
|
{ |
| 892 |
|
firstParty = 1; |
| 1022 |
|
fstream file; |
| 1023 |
|
file.open((install_iter->path().string() + "/Mod_Info.cfg").c_str()); |
| 1024 |
|
if (!file.fail()) |
| 1025 |
< |
ModPackage updatePackage = fileToModPackage(file, install_iter->path().filename()); |
| 1025 |
> |
updatePackage = fileToModPackage(file, install_iter->path().filename()); |
| 1026 |
|
else |
| 1027 |
|
{ |
| 1028 |
|
file.close(); |
| 1029 |
|
continue; |
| 1030 |
|
} |
| 1031 |
< |
if (exists("packages" + install_iter->path().filename() + "/Mod_Info.cfg")) |
| 1031 |
> |
if (exists("packages/" + install_iter->path().filename() + "/Mod_Info.cfg")) |
| 1032 |
|
{ |
| 1033 |
|
file.close(); |
| 1034 |
< |
file.open(("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); |
| 1034 |
> |
file.clear(); |
| 1035 |
> |
file.open(("packages/" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); |
| 1036 |
|
if (!file.fail()) |
| 1037 |
< |
ModPackage installedPackage = fileToModPackage(file, install_iter->path().filename()); |
| 1037 |
> |
installedPackage = fileToModPackage(file, install_iter->path().filename()); |
| 1038 |
|
file.close(); |
| 1039 |
|
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1040 |
|
{ |
| 1049 |
|
} |
| 1050 |
|
} |
| 1051 |
|
} |
| 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 |
– |
} |
| 1052 |
|
} |
| 1053 |
|
} |
| 1054 |
|
catch (exception & ex) { |
| 1068 |
|
string strDaodanVersion = "Daodan_Version"; |
| 1069 |
|
string strOniSplitVersion = "OniSplit_Version"; |
| 1070 |
|
string strGUIWinVersion = "GUI_Win_Version"; |
| 1071 |
< |
string strGUIMacVersion = "GUI_Mac_Version"; |
| 1071 |
> |
string strGUIMacVersion = "GUI_Mac_Version"; |
| 1072 |
|
string strReglobalize = "Reglobalize"; |
| 1073 |
|
string strDeleteList = "Delete_List"; |
| 1074 |
|
string strArrow = "->"; |
| 1310 |
|
return true; // returning 'true' tells the Installer to quit itself ASAP so it can be replaced by the process that is now running |
| 1311 |
|
} |
| 1312 |
|
|
| 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 |
– |
|
| 1313 |
|
bool ProcessAEUpdate(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) |
| 1314 |
|
{ |
| 1315 |
+ |
try { |
| 1316 |
|
fstream file; |
| 1317 |
|
string line; |
| 1318 |
|
vector<string> tokens, updateStarted; |
| 1332 |
|
string strOniApp = "Oni.exe"; |
| 1333 |
|
#else |
| 1334 |
|
string strOniApp = "Oni.app"; |
| 1383 |
– |
#endif |
| 1335 |
|
bool needNewTrashDir = false; |
| 1336 |
+ |
#endif |
| 1337 |
+ |
|
| 1338 |
|
bool readingVerAndDate = false; |
| 1339 |
|
|
| 1340 |
|
#ifdef WIN32 |
| 1341 |
< |
string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted |
| 1341 |
> |
//remove readonly attrib from files. |
| 1342 |
> |
setStatusArea("Removing readonly attribute..."); |
| 1343 |
> |
system("attrib -r ./* /s"); |
| 1344 |
> |
system("attrib -r ../Oni.exe /s"); |
| 1345 |
> |
system("attrib -r ../binkw32.dll /s"); |
| 1346 |
> |
|
| 1347 |
|
#else |
| 1348 |
|
FILE *fUserName = NULL; |
| 1349 |
|
char chrUserName[32]; |
| 1378 |
|
if (readingVerAndDate && tokens.capacity() >= 3) |
| 1379 |
|
tokenize(tokens[2], updateStarted, "-"); |
| 1380 |
|
} |
| 1381 |
+ |
#ifndef WIN32 |
| 1382 |
|
if (updateStarted.capacity() < 3) |
| 1383 |
|
needNewTrashDir = true; |
| 1384 |
|
else |
| 1388 |
|
if (!exists(strTrashDir)) |
| 1389 |
|
needNewTrashDir = true; |
| 1390 |
|
} |
| 1391 |
+ |
#endif |
| 1392 |
|
} |
| 1393 |
|
#ifndef WIN32 |
| 1394 |
|
if (!*installerJustUpdated || needNewTrashDir) // prepare a new directory for deleted files to go to |
| 1405 |
|
// Special code to replace our special files -- the Oni app, OniSplit, the Daodan DLL, and the GUI for OniSplit |
| 1406 |
|
if (exists(strPathToEUFN + strOniApp)) |
| 1407 |
|
{ |
| 1408 |
< |
if (exists(strOniApp)) |
| 1409 |
< |
rename((path)strOniApp, (path)(strTrashDir + strOniApp)); |
| 1410 |
< |
rename((path)(strPathToEUFN + strOniApp), (path)strOniApp); |
| 1408 |
> |
if (exists("../" + strOniApp)) |
| 1409 |
> |
#ifdef WIN32 |
| 1410 |
> |
remove((path)("../" + strOniApp)); |
| 1411 |
> |
#else |
| 1412 |
> |
rename((path)("../" + strOniApp), (path)(strTrashDir + strOniApp)); |
| 1413 |
> |
#endif |
| 1414 |
> |
rename((path)(strPathToEUFN + strOniApp), (path)("../" + strOniApp)); |
| 1415 |
|
} |
| 1416 |
|
if (updateAE->OniSplitVersion.compare(currentAE->OniSplitVersion) >= 1) |
| 1417 |
|
{ |
| 1418 |
|
if (exists(strPathToEUFNInstall + strOniSplit)) |
| 1419 |
|
{ |
| 1420 |
|
if (exists(strOniSplit)) |
| 1421 |
+ |
#ifdef WIN32 |
| 1422 |
+ |
remove((path)strOniSplit); |
| 1423 |
+ |
#else |
| 1424 |
|
rename((path)strOniSplit, (path)(strTrashDir + strOniSplit)); |
| 1425 |
+ |
#endif |
| 1426 |
|
rename((path)(strPathToEUFNInstall + strOniSplit), (path)strOniSplit); |
| 1427 |
|
} |
| 1428 |
|
} |
| 1432 |
|
if (exists(strPathToEUFN + strDaodan)) |
| 1433 |
|
{ |
| 1434 |
|
if (exists(("../" + strDaodan))) |
| 1435 |
< |
rename((path)("../" + strDaodan), (path)(strTrashDir + strDaodan)); |
| 1435 |
> |
remove((path)("../" + strDaodan)); |
| 1436 |
|
rename((path)(strPathToEUFN + strDaodan), (path)("../" + strDaodan)); |
| 1437 |
|
} |
| 1438 |
|
} |
| 1441 |
|
if (exists(strPathToEUFNInstall + strWinGUI)) |
| 1442 |
|
{ |
| 1443 |
|
if (exists((path)strWinGUI)) |
| 1444 |
< |
rename((path)strWinGUI, (path)(strTrashDir + strWinGUI)); |
| 1444 |
> |
remove((path)strWinGUI); |
| 1445 |
|
if (exists(strWinGUILang)) |
| 1446 |
< |
rename((path)strWinGUILang, (path)(strTrashDir + strWinGUILang)); |
| 1446 |
> |
remove((path)strWinGUILang); |
| 1447 |
|
rename((path)(strPathToEUFNInstall + strWinGUI), (path)strWinGUI); |
| 1448 |
|
rename((path)(strPathToEUFNInstall + strWinGUILang), (path)strWinGUILang); |
| 1449 |
|
} |
| 1476 |
|
while (curPos != string::npos && curPos < thePath.size()) |
| 1477 |
|
{ |
| 1478 |
|
aParentPath = aParentPath + thePath.substr(lastPos, curPos - lastPos); |
| 1479 |
+ |
#ifndef WIN32 |
| 1480 |
|
if (!exists(strTrashDir + aParentPath)) |
| 1481 |
|
create_directory(strTrashDir + aParentPath); |
| 1482 |
+ |
#endif |
| 1483 |
|
lastPos = curPos + 1; |
| 1484 |
|
curPos = thePath.find("/", lastPos); |
| 1485 |
|
aParentPath = aParentPath + "/"; |
| 1524 |
|
for (vector<string>::iterator iter = filesToMove.begin(); iter != filesToMove.end(); iter++) |
| 1525 |
|
{ |
| 1526 |
|
if (exists(strPathToPackages + strGlobalize + *iter)) |
| 1527 |
+ |
#ifdef WIN32 |
| 1528 |
+ |
remove((path)(strPathToPackages + strGlobalize + *iter)); |
| 1529 |
+ |
#else |
| 1530 |
|
rename((path)(strPathToPackages + strGlobalize + *iter), (path)(strTrashDir + *iter)); |
| 1531 |
+ |
#endif |
| 1532 |
|
rename((path)(strPathToEUFNPackages + strGlobalize + *iter), (path)(strPathToPackages + strGlobalize + *iter)); |
| 1533 |
|
} |
| 1534 |
|
|
| 1535 |
|
// Clean up after ourselves, trashing any packages or programs in the update package that are not newer than the current AE |
| 1536 |
+ |
#ifdef WIN32 |
| 1537 |
+ |
remove_all((path)strPathToEUFN); |
| 1538 |
+ |
#else |
| 1539 |
|
create_directory(strTrashDir + "Unneeded update files"); |
| 1540 |
|
rename((path)strPathToEUFN, (path)(strTrashDir + "Unneeded update files/" + strEUFN)); |
| 1541 |
< |
|
| 1541 |
> |
#endif |
| 1542 |
|
// Write to log that we are finished with update |
| 1543 |
|
ptime end_time(second_clock::local_time()); |
| 1544 |
|
string progressMsg2 = "Edition was updated to:\n" + |
| 1556 |
|
CheckForGlobalization(true); // the 'true' value forces re-globalization |
| 1557 |
|
|
| 1558 |
|
globalPackages = getPackages(); // refresh the list in memory |
| 1559 |
< |
// TODO: Refresh the packages list in the window |
| 1560 |
< |
|
| 1559 |
> |
wxCommandEvent e; |
| 1560 |
> |
TheWindow->OnRefreshButtonClick( e ); |
| 1561 |
|
return true; |
| 1562 |
+ |
} |
| 1563 |
+ |
catch (exception & ex) |
| 1564 |
+ |
{ |
| 1565 |
+ |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1566 |
+ |
return false; |
| 1567 |
+ |
} |
| 1568 |
+ |
|
| 1569 |
|
} |
| 1570 |
|
|
| 1571 |
|
void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages) |
| 1618 |
|
if (!file.fail()) |
| 1619 |
|
{ |
| 1620 |
|
installedPackage = fileToModPackage(file, updtFolder); |
| 1621 |
< |
file.close(); |
| 1622 |
< |
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1623 |
< |
{ |
| 1624 |
< |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
| 1625 |
< |
{ |
| 1621 |
> |
} |
| 1622 |
> |
file.close(); |
| 1623 |
> |
} |
| 1624 |
> |
file.close(); |
| 1625 |
> |
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1626 |
> |
{ |
| 1627 |
> |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
| 1628 |
> |
{ |
| 1629 |
> |
if(exists(strPathToPackages + "/" + updatePackage.modStringName)) { |
| 1630 |
|
#ifdef WIN32 |
| 1631 |
< |
remove_all((path)(strPathToPackages + "/" + installedPackage.modStringName)); |
| 1631 |
> |
remove_all((path)(strPathToPackages + "/" + updatePackage.modStringName)); |
| 1632 |
|
#else |
| 1633 |
< |
if (needNewTrashDir) |
| 1634 |
< |
{ |
| 1635 |
< |
strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast<string>(tmStartTime.tm_hour) + "-" + |
| 1636 |
< |
boost::lexical_cast<string>(tmStartTime.tm_min) + "-" + boost::lexical_cast<string>(tmStartTime.tm_sec) + "/"; |
| 1637 |
< |
create_directory(strTrashDir); |
| 1638 |
< |
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)); |
| 1633 |
> |
if (needNewTrashDir) |
| 1634 |
> |
{ |
| 1635 |
> |
strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast<string>(tmStartTime.tm_hour) + "-" + |
| 1636 |
> |
boost::lexical_cast<string>(tmStartTime.tm_min) + "-" + boost::lexical_cast<string>(tmStartTime.tm_sec) + "/"; |
| 1637 |
> |
create_directory(strTrashDir); |
| 1638 |
> |
needNewTrashDir = false; |
| 1639 |
|
} |
| 1640 |
+ |
rename((path)(strPathToPackages + "/" + updatePackage.modStringName), (path)(strTrashDir + updatePackage.modStringName)); |
| 1641 |
+ |
#endif |
| 1642 |
|
} |
| 1643 |
+ |
rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); |
| 1644 |
|
} |
| 1658 |
– |
else |
| 1659 |
– |
file.close(); |
| 1645 |
|
} |
| 1661 |
– |
file.close(); |
| 1662 |
– |
file.clear(); |
| 1646 |
|
} |
| 1647 |
|
} |
| 1648 |
|
} |
| 1650 |
|
{ |
| 1651 |
|
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1652 |
|
} |
| 1653 |
+ |
wxCommandEvent e; |
| 1654 |
+ |
TheWindow->OnRefreshButtonClick( e ); |
| 1655 |
|
} |
| 1656 |
|
|
| 1657 |
|
/* MakePathLocalToGlobalize is a function used once by ProcessAEUpdate() that takes a file in an \ |