| 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 |
|
{ |
| 310 |
|
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 |
| 311 |
|
run Oni before :-p */ |
| 312 |
|
string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for Edition/ (Oni wants folder that *contains* the GDF) |
| 312 |
– |
//bad Iritscen, bad! fixed buffers can cause crashes. |
| 313 |
– |
/*char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '"; |
| 314 |
– |
strcat(prefsCommand, fullAEpath.c_str()); |
| 315 |
– |
strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters |
| 316 |
– |
*/ |
| 313 |
|
string prefsCommand = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '" |
| 314 |
|
+ fullAEpath + "'"; |
| 315 |
|
system(prefsCommand.c_str()); |
| 592 |
|
else if(splitInstances == false){ |
| 593 |
|
directory_iterator end_iter; |
| 594 |
|
|
| 595 |
< |
for ( directory_iterator dir_itr( vanilla_dir ); |
| 596 |
< |
dir_itr != end_iter; |
| 597 |
< |
++dir_itr ) |
| 598 |
< |
{ |
| 599 |
< |
if ( is_directory( dir_itr->status() ) ) |
| 600 |
< |
{ |
| 601 |
< |
numberOfDats++; |
| 595 |
> |
|
| 596 |
> |
char levelnums[256] = {0}; |
| 597 |
> |
|
| 598 |
> |
|
| 599 |
> |
|
| 600 |
> |
for(int k = 0; k < 256; k++) { |
| 601 |
> |
if( exists( (path)("./VanillaDats/level" + lexical_cast<std::string>(k) + "_final/") ) ) { |
| 602 |
> |
levelnums[k] = 1; |
| 603 |
> |
|
| 604 |
|
} |
| 605 |
|
} |
| 606 |
< |
|
| 606 |
> |
|
| 607 |
> |
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 608 |
> |
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 609 |
> |
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 610 |
> |
for(int k = 0; k < 256; k++) { |
| 611 |
> |
if( globalPackages[j].hasOnis && |
| 612 |
> |
exists( (path)("packages/" + globalPackages[j].modStringName + "/oni/level" + lexical_cast<std::string>(k) + "_final/") ) ) { |
| 613 |
> |
levelnums[k] = 1; |
| 614 |
> |
|
| 615 |
> |
} |
| 616 |
> |
} |
| 617 |
> |
} |
| 618 |
> |
} |
| 619 |
> |
} |
| 620 |
> |
for (int levelnum = 0; levelnum < 256; levelnum++) |
| 621 |
> |
if (levelnums[levelnum]) |
| 622 |
> |
numberOfDats++; |
| 623 |
> |
|
| 624 |
|
out << numberOfDats; |
| 625 |
|
datString = out.str(); |
| 626 |
< |
|
| 627 |
< |
for ( directory_iterator dir_itr( vanilla_dir ); |
| 613 |
< |
dir_itr != end_iter; |
| 614 |
< |
++dir_itr ) |
| 615 |
< |
{ |
| 626 |
> |
|
| 627 |
> |
for(int levelnum = 0; levelnum < 256; levelnum++) { |
| 628 |
|
try |
| 629 |
|
{ |
| 630 |
< |
if ( is_directory( dir_itr->status() ) ) |
| 630 |
> |
if ( levelnums[levelnum] ) |
| 631 |
|
{ |
| 632 |
< |
importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " "; |
| 632 |
> |
importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + "level" + lexical_cast<std::string>(levelnum) + "_Final "; |
| 633 |
|
for (unsigned int i = 0; i < installedMods.size(); ++i) { |
| 634 |
< |
if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename() )) |
| 635 |
< |
importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename(); |
| 634 |
> |
if (exists((path)("packages/" + installedMods[i] + "/oni/level" + lexical_cast<std::string>(levelnum) + "_final") )) |
| 635 |
> |
importCommand += " packages/" + installedMods[i] + "/oni/level" + lexical_cast<std::string>(levelnum) + "_Final"; |
| 636 |
|
} |
| 637 |
< |
importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; |
| 637 |
> |
importCommand += " ../GameDataFolder/level" + lexical_cast<std::string>(levelnum) + "_Final.dat >> Install.log"; |
| 638 |
|
|
| 639 |
|
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
| 640 |
|
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
| 641 |
< |
dir_itr->path().filename() + " "); |
| 641 |
> |
"level" + lexical_cast<std::string>(levelnum) + "_Final"+ " "); |
| 642 |
|
system(importCommand.c_str()); |
| 643 |
|
j++; |
| 644 |
|
} |
| 658 |
|
vector<string> skippedfolders; |
| 659 |
|
|
| 660 |
|
ofstream BSLlog("BSL.log"); |
| 661 |
+ |
if(exists("../GameDataFolder/BSLBackup/")) { |
| 662 |
+ |
remove_all("../GameDataFolder/BSLBackup/"); |
| 663 |
+ |
} |
| 664 |
+ |
else { |
| 665 |
+ |
create_directory("../GameDataFolder/BSLBackup/"); |
| 666 |
+ |
} |
| 667 |
+ |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 668 |
|
for ( directory_iterator dir_itr( "../GameDataFolder/IGMD/" ), end_itr; |
| 669 |
|
dir_itr != end_itr; |
| 670 |
|
++dir_itr ) { |
| 677 |
|
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 678 |
|
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 679 |
|
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 680 |
< |
if(!(globalPackages[j].hasAddon || globalPackages[j].hasBSL)) break; //skip non-BSL |
| 680 |
> |
if(globalPackages[j].hasBSL) break; //skip non-BSL |
| 681 |
|
if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { |
| 682 |
|
copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); |
| 683 |
|
BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; |
| 686 |
|
} |
| 687 |
|
} |
| 688 |
|
|
| 689 |
+ |
|
| 690 |
+ |
|
| 691 |
|
ModPackage emptyPackage; |
| 692 |
|
emptyPackage.modStringName = "VanillaBSL"; |
| 693 |
|
emptyPackage.hasBSL = 1; |
| 694 |
|
copyBSL("packages/VanillaBSL/IGMD", BSLfolders, emptyPackage); |
| 695 |
|
BSLlog.close(); |
| 696 |
< |
|
| 696 |
> |
|
| 697 |
> |
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 698 |
> |
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 699 |
> |
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 700 |
> |
if(!globalPackages[j].hasAddon) break; //skip non-BSL |
| 701 |
> |
if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { |
| 702 |
> |
copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); |
| 703 |
> |
BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; |
| 704 |
> |
} |
| 705 |
> |
} |
| 706 |
> |
} |
| 707 |
> |
} |
| 708 |
> |
|
| 709 |
|
logfile << "Writing config file"; |
| 710 |
|
writeInstalledMods(installedMods); |
| 711 |
|
setProgressBar(1000); |
| 746 |
|
if ( is_directory( dir_itr->path() ) && dir_itr->path().string() != ".svn" ) { |
| 747 |
|
BSLlog << "Testing " << dir_itr->path().string() << " HasBSL: " << pkg.hasBSL << " HasAddon: " << pkg.hasAddon << "\n"; |
| 748 |
|
int skip_folder = 0; |
| 749 |
< |
|
| 750 |
< |
for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders |
| 751 |
< |
BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; |
| 752 |
< |
if(dir_itr->path().filename() == BSLfolders[k]) { |
| 753 |
< |
skip_folder = 1; |
| 754 |
< |
BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; |
| 755 |
< |
break; |
| 749 |
> |
if(!pkg.hasAddon) { |
| 750 |
> |
for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders |
| 751 |
> |
BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; |
| 752 |
> |
if(dir_itr->path().filename() == BSLfolders[k]) { |
| 753 |
> |
skip_folder = 1; |
| 754 |
> |
BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; |
| 755 |
> |
break; |
| 756 |
> |
} |
| 757 |
|
} |
| 758 |
|
} |
| 759 |
|
if (!skip_folder && !exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/ignore.txt")) { |
| 768 |
|
copy_file(bsl_itr->path(), "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 769 |
|
} |
| 770 |
|
} |
| 771 |
< |
BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon |
| 772 |
< |
BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; |
| 771 |
> |
if( !pkg.hasAddon ) { |
| 772 |
> |
BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon |
| 773 |
> |
BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; |
| 774 |
> |
} |
| 775 |
|
} |
| 776 |
|
} |
| 777 |
|
} |
| 877 |
|
return UPDATE_LOG_READ_ERR; |
| 878 |
|
} |
| 879 |
|
|
| 880 |
< |
// Is there an update folder, and is it a monthly release or a patch? |
| 880 |
> |
// Is there an update in the updates/ folder, and is it a monthly release or a patch? |
| 881 |
|
bool firstParty = 0; |
| 882 |
+ |
// First create the folder if it's missing, so users are never left wondering where updates are supposed to be put |
| 883 |
+ |
if (!exists("../updates")) |
| 884 |
+ |
create_directory("../updates"); |
| 885 |
|
if (exists("../updates/Edition")) |
| 886 |
|
{ |
| 887 |
|
firstParty = 1; |
| 984 |
|
return UPDATE_LOG_READ_ERR; |
| 985 |
|
} |
| 986 |
|
|
| 987 |
< |
if (updateAE->AEVersion.compare(currentAE->AEVersion) >= 1) // is the release update newer than what's installed? |
| 987 |
> |
if (updateAE->AEVersion.compare(currentAE->AEVersion) > 0) // is the release update newer than what's installed? |
| 988 |
|
{ |
| 950 |
– |
if (!strEUFN.compare("Edition-patch")) // if update is a patch... |
| 951 |
– |
{ |
| 952 |
– |
if (currentAE->AEVersion.compare(updateAE->AEVersion.substr(0, updateAE->AEVersion.length() - 1))) // ...is it for a different month? |
| 953 |
– |
return UPDATE_MNTH_REQD_ERR; |
| 954 |
– |
} |
| 989 |
|
string strNewInstallerPath = "../updates/" + strEUFN + "/install/" + strInstallerName; |
| 990 |
|
string installerVersion = INSTALLER_VERSION; |
| 991 |
|
if (updateAE->InstallerVersion.compare(installerVersion) >= 1) |
| 998 |
|
else |
| 999 |
|
return UPDATE_SIMP_AVAIL; |
| 1000 |
|
} |
| 1001 |
+ |
else |
| 1002 |
+ |
return UPDATE_MNTH_REQD_ERR; |
| 1003 |
|
} |
| 1004 |
|
try |
| 1005 |
|
{ |
| 1011 |
|
ModPackage installedPackage, updatePackage; |
| 1012 |
|
if (is_directory(install_iter->path()) && exists(install_iter->path().string() + "/Mod_Info.cfg")) |
| 1013 |
|
{ |
| 978 |
– |
string blah =install_iter->path().string() + "/Mod_Info.cfg"; |
| 979 |
– |
string blah2 = "packages/" + install_iter->path().filename() + "/Mod_Info.cfg"; |
| 1014 |
|
fstream file; |
| 1015 |
|
file.open((install_iter->path().string() + "/Mod_Info.cfg").c_str()); |
| 1016 |
|
if (!file.fail()) |
| 1304 |
|
|
| 1305 |
|
bool ProcessAEUpdate(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) |
| 1306 |
|
{ |
| 1307 |
+ |
try { |
| 1308 |
|
fstream file; |
| 1309 |
|
string line; |
| 1310 |
|
vector<string> tokens, updateStarted; |
| 1324 |
|
string strOniApp = "Oni.exe"; |
| 1325 |
|
#else |
| 1326 |
|
string strOniApp = "Oni.app"; |
| 1292 |
– |
#endif |
| 1327 |
|
bool needNewTrashDir = false; |
| 1328 |
+ |
#endif |
| 1329 |
+ |
|
| 1330 |
|
bool readingVerAndDate = false; |
| 1331 |
|
|
| 1332 |
|
#ifdef WIN32 |
| 1333 |
< |
string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted |
| 1333 |
> |
//remove readonly attrib from files. |
| 1334 |
> |
setStatusArea("Removing readonly attribute..."); |
| 1335 |
> |
system("attrib -r ./* /s"); |
| 1336 |
> |
system("attrib -r ../Oni.exe /s"); |
| 1337 |
> |
system("attrib -r ../binkw32.dll /s"); |
| 1338 |
> |
|
| 1339 |
|
#else |
| 1340 |
|
FILE *fUserName = NULL; |
| 1341 |
|
char chrUserName[32]; |
| 1370 |
|
if (readingVerAndDate && tokens.capacity() >= 3) |
| 1371 |
|
tokenize(tokens[2], updateStarted, "-"); |
| 1372 |
|
} |
| 1373 |
+ |
#ifndef WIN32 |
| 1374 |
|
if (updateStarted.capacity() < 3) |
| 1375 |
|
needNewTrashDir = true; |
| 1376 |
|
else |
| 1380 |
|
if (!exists(strTrashDir)) |
| 1381 |
|
needNewTrashDir = true; |
| 1382 |
|
} |
| 1383 |
+ |
#endif |
| 1384 |
|
} |
| 1385 |
|
#ifndef WIN32 |
| 1386 |
|
if (!*installerJustUpdated || needNewTrashDir) // prepare a new directory for deleted files to go to |
| 1397 |
|
// Special code to replace our special files -- the Oni app, OniSplit, the Daodan DLL, and the GUI for OniSplit |
| 1398 |
|
if (exists(strPathToEUFN + strOniApp)) |
| 1399 |
|
{ |
| 1400 |
< |
if (exists(strOniApp)) |
| 1401 |
< |
rename((path)strOniApp, (path)(strTrashDir + strOniApp)); |
| 1402 |
< |
rename((path)(strPathToEUFN + strOniApp), (path)strOniApp); |
| 1400 |
> |
if (exists("../" + strOniApp)) |
| 1401 |
> |
#ifdef WIN32 |
| 1402 |
> |
remove((path)("../" + strOniApp)); |
| 1403 |
> |
#else |
| 1404 |
> |
rename((path)("../" + strOniApp), (path)(strTrashDir + strOniApp)); |
| 1405 |
> |
#endif |
| 1406 |
> |
rename((path)(strPathToEUFN + strOniApp), (path)("../" + strOniApp)); |
| 1407 |
|
} |
| 1408 |
|
if (updateAE->OniSplitVersion.compare(currentAE->OniSplitVersion) >= 1) |
| 1409 |
|
{ |
| 1410 |
|
if (exists(strPathToEUFNInstall + strOniSplit)) |
| 1411 |
|
{ |
| 1412 |
|
if (exists(strOniSplit)) |
| 1413 |
+ |
#ifdef WIN32 |
| 1414 |
+ |
remove((path)strOniSplit); |
| 1415 |
+ |
#else |
| 1416 |
|
rename((path)strOniSplit, (path)(strTrashDir + strOniSplit)); |
| 1417 |
+ |
#endif |
| 1418 |
|
rename((path)(strPathToEUFNInstall + strOniSplit), (path)strOniSplit); |
| 1419 |
|
} |
| 1420 |
|
} |
| 1424 |
|
if (exists(strPathToEUFN + strDaodan)) |
| 1425 |
|
{ |
| 1426 |
|
if (exists(("../" + strDaodan))) |
| 1427 |
< |
rename((path)("../" + strDaodan), (path)(strTrashDir + strDaodan)); |
| 1427 |
> |
remove((path)("../" + strDaodan)); |
| 1428 |
|
rename((path)(strPathToEUFN + strDaodan), (path)("../" + strDaodan)); |
| 1429 |
|
} |
| 1430 |
|
} |
| 1433 |
|
if (exists(strPathToEUFNInstall + strWinGUI)) |
| 1434 |
|
{ |
| 1435 |
|
if (exists((path)strWinGUI)) |
| 1436 |
< |
rename((path)strWinGUI, (path)(strTrashDir + strWinGUI)); |
| 1436 |
> |
remove((path)strWinGUI); |
| 1437 |
|
if (exists(strWinGUILang)) |
| 1438 |
< |
rename((path)strWinGUILang, (path)(strTrashDir + strWinGUILang)); |
| 1438 |
> |
remove((path)strWinGUILang); |
| 1439 |
|
rename((path)(strPathToEUFNInstall + strWinGUI), (path)strWinGUI); |
| 1440 |
|
rename((path)(strPathToEUFNInstall + strWinGUILang), (path)strWinGUILang); |
| 1441 |
|
} |
| 1468 |
|
while (curPos != string::npos && curPos < thePath.size()) |
| 1469 |
|
{ |
| 1470 |
|
aParentPath = aParentPath + thePath.substr(lastPos, curPos - lastPos); |
| 1471 |
+ |
#ifndef WIN32 |
| 1472 |
|
if (!exists(strTrashDir + aParentPath)) |
| 1473 |
|
create_directory(strTrashDir + aParentPath); |
| 1474 |
+ |
#endif |
| 1475 |
|
lastPos = curPos + 1; |
| 1476 |
|
curPos = thePath.find("/", lastPos); |
| 1477 |
|
aParentPath = aParentPath + "/"; |
| 1486 |
|
|
| 1487 |
|
ProcessPackageUpdates(strPathToEUFNPackages, strPathToPackages); |
| 1488 |
|
|
| 1489 |
< |
// 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... |
| 1490 |
< |
// ...and folders which do not exist in the current AE will be created there |
| 1491 |
< |
vector<string> foldersToMake, filesToMove; |
| 1492 |
< |
string thePath; |
| 1489 |
> |
// Next, move over files in the update's Globalize folder; subfolders which do not exist in the current AE will be created by Boost's... |
| 1490 |
> |
// ...create_directories() function |
| 1491 |
> |
string strPath; |
| 1492 |
> |
path thePath; |
| 1493 |
|
for (recursive_directory_iterator dir_itr(strPathToEUFNPackages + strGlobalize), end_itr; dir_itr != end_itr; ++dir_itr) |
| 1494 |
|
{ |
| 1495 |
< |
thePath = dir_itr->path().string(); |
| 1496 |
< |
MakePathLocalToGlobalize(&thePath); |
| 1495 |
> |
strPath = dir_itr->path().string(); |
| 1496 |
> |
MakePathLocalToGlobalize(&strPath); |
| 1497 |
> |
thePath = (path)strPath; |
| 1498 |
|
if (is_regular_file(dir_itr->status())) |
| 1499 |
|
{ |
| 1500 |
< |
if (dir_itr->filename().at(0) != '.') // skip over dot-files, which are invisible in Unix |
| 1501 |
< |
filesToMove.push_back(thePath); |
| 1502 |
< |
} |
| 1503 |
< |
else if (is_directory(dir_itr->status())) |
| 1504 |
< |
{ |
| 1505 |
< |
if (!exists(strPathToPackages + strGlobalize + thePath)) |
| 1506 |
< |
foldersToMake.push_back(thePath); |
| 1500 |
> |
if (thePath.filename().at(0) != '.') // skip over dot-files, which are invisible in Unix |
| 1501 |
> |
{ |
| 1502 |
> |
if (exists(strPathToPackages + strGlobalize + strPath)) |
| 1503 |
> |
{ |
| 1504 |
> |
#ifdef WIN32 |
| 1505 |
> |
remove((path)(strPathToPackages + strGlobalize + strPath)); |
| 1506 |
> |
#else |
| 1507 |
> |
create_directories((path)(strTrashDir + thePath.parent_path().string())); |
| 1508 |
> |
rename((path)(strPathToPackages + strGlobalize + strPath), (path)(strTrashDir + strPath)); |
| 1509 |
> |
#endif |
| 1510 |
> |
rename((path)(strPathToEUFNPackages + strGlobalize + strPath), (path)(strPathToPackages + strGlobalize + strPath)); |
| 1511 |
> |
} |
| 1512 |
> |
else |
| 1513 |
> |
{ |
| 1514 |
> |
int slashLoc = 0; |
| 1515 |
> |
slashLoc = strPath.find("/", 0); |
| 1516 |
> |
if (slashLoc != string::npos) // then path contains slashes, so we need to make sure its parents' paths exist before moving it |
| 1517 |
> |
create_directories((path)(strPathToPackages + strGlobalize + thePath.parent_path().string())); |
| 1518 |
> |
rename((path)(strPathToEUFNPackages + strGlobalize + strPath), (path)(strPathToPackages + strGlobalize + strPath)); |
| 1519 |
> |
} |
| 1520 |
> |
} |
| 1521 |
|
} |
| 1522 |
|
} |
| 1455 |
– |
// Sort the foldersToMake strings by length, which is a fast solution to the problem of "How do we make sure we create folder 'parent/'... |
| 1456 |
– |
// ...before folder 'parent/child/'"? |
| 1457 |
– |
sort(foldersToMake.begin(), foldersToMake.end(), SortBySize); // SortBySize is a custom comparison function found later in this source file |
| 1458 |
– |
// First make the folders that don't exist in the current AE, so all the files have a place to go |
| 1459 |
– |
for (vector<string>::iterator iter = foldersToMake.begin(); iter != foldersToMake.end(); iter++) |
| 1460 |
– |
{ |
| 1461 |
– |
create_directory(strPathToPackages + strGlobalize + *iter); |
| 1462 |
– |
} |
| 1463 |
– |
for (vector<string>::iterator iter = filesToMove.begin(); iter != filesToMove.end(); iter++) |
| 1464 |
– |
{ |
| 1465 |
– |
if (exists(strPathToPackages + strGlobalize + *iter)) |
| 1466 |
– |
rename((path)(strPathToPackages + strGlobalize + *iter), (path)(strTrashDir + *iter)); |
| 1467 |
– |
rename((path)(strPathToEUFNPackages + strGlobalize + *iter), (path)(strPathToPackages + strGlobalize + *iter)); |
| 1468 |
– |
} |
| 1523 |
|
|
| 1524 |
|
// Clean up after ourselves, trashing any packages or programs in the update package that are not newer than the current AE |
| 1525 |
+ |
#ifdef WIN32 |
| 1526 |
+ |
remove_all((path)strPathToEUFN); |
| 1527 |
+ |
#else |
| 1528 |
|
create_directory(strTrashDir + "Unneeded update files"); |
| 1529 |
|
rename((path)strPathToEUFN, (path)(strTrashDir + "Unneeded update files/" + strEUFN)); |
| 1530 |
< |
|
| 1530 |
> |
#endif |
| 1531 |
|
// Write to log that we are finished with update |
| 1532 |
|
ptime end_time(second_clock::local_time()); |
| 1533 |
|
string progressMsg2 = "Edition was updated to:\n" + |
| 1545 |
|
CheckForGlobalization(true); // the 'true' value forces re-globalization |
| 1546 |
|
|
| 1547 |
|
globalPackages = getPackages(); // refresh the list in memory |
| 1548 |
< |
// TODO: Refresh the packages list in the window |
| 1549 |
< |
|
| 1548 |
> |
wxCommandEvent e; |
| 1549 |
> |
TheWindow->OnRefreshButtonClick( e ); |
| 1550 |
|
return true; |
| 1551 |
+ |
} |
| 1552 |
+ |
catch (exception & ex) |
| 1553 |
+ |
{ |
| 1554 |
+ |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1555 |
+ |
return false; |
| 1556 |
+ |
} |
| 1557 |
|
} |
| 1558 |
< |
extern MainWindow* TheWindow; |
| 1558 |
> |
|
| 1559 |
|
void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages) |
| 1560 |
|
{ |
| 1561 |
|
ptime startTime(second_clock::local_time()); |
| 1738 |
|
|
| 1739 |
|
} |
| 1740 |
|
else if(from_ph.filename() != ".svn") |
| 1741 |
< |
{ |
| 1742 |
< |
path destination; |
| 1743 |
< |
if(!exists(to_ph)) |
| 1744 |
< |
{ |
| 1745 |
< |
destination=to_ph; |
| 1746 |
< |
} |
| 1747 |
< |
else |
| 1748 |
< |
{ |
| 1749 |
< |
destination=to_ph/from_ph.filename(); |
| 1750 |
< |
} |
| 1741 |
> |
{ |
| 1742 |
> |
path destination; |
| 1743 |
> |
if(!exists(to_ph)) |
| 1744 |
> |
{ |
| 1745 |
> |
destination=to_ph; |
| 1746 |
> |
} |
| 1747 |
> |
else |
| 1748 |
> |
{ |
| 1749 |
> |
destination=to_ph/from_ph.filename(); |
| 1750 |
> |
} |
| 1751 |
|
|
| 1752 |
< |
for(directory_iterator i(from_ph); i!=directory_iterator(); ++i) |
| 1752 |
> |
for(directory_iterator i(from_ph); i!=directory_iterator(); ++i) |
| 1753 |
|
{ |
| 1754 |
|
//the idiot who coded this in the first place (not me) |
| 1755 |
|
//forgot to make a new directory. Exception city. x_x |
| 1756 |
< |
create_directory(destination); |
| 1757 |
< |
copy(*i,destination/i->filename()); |
| 1756 |
> |
create_directory(destination); |
| 1757 |
> |
copy(*i, destination/i->filename()); |
| 1758 |
|
} |
| 1759 |
|
} |
| 1760 |
|
} |