| 24 |
|
using namespace boost::gregorian; |
| 25 |
|
using namespace boost::posix_time; |
| 26 |
|
|
| 27 |
– |
// externs declared in installer.h |
| 27 |
|
string strInstallCfg = "../GameDataFolder/Add.cfg"; |
| 28 |
|
string strEUFN = "Edition"; // GetUpdateStatus() may set this to "Edition-patch" later, but this is the assumed name of the new Edition folder in Updates/ |
| 29 |
+ |
extern MainWindow* TheWindow; |
| 30 |
|
|
| 31 |
|
int globalizeData(void) |
| 32 |
|
{ |
| 231 |
|
|
| 232 |
|
|
| 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()); |
| 236 |
|
remove( "../GameDataFolder/level" + levels[i] + "_Final/AKEV" ); |
| 237 |
|
} |
| 238 |
|
|
| 246 |
|
for (int i = 0; i < 15; i++) |
| 247 |
|
{ |
| 248 |
|
logfile << "\tReimporting level" << levels[i] << "_Final.oni\n"; |
| 249 |
< |
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"); |
| 251 |
|
logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" |
| 252 |
|
+ levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str() << '\n'; |
| 253 |
|
string sys_str = (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" |
| 308 |
|
/* On Mac only, set the current GDF to the AE GDF by writing to Oni's global preferences file (thankfully a standard OS X ".plist" XML file). |
| 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 |
| 310 |
|
run Oni before :-p */ |
| 311 |
< |
string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for Edition/ (Oni wants the folder that *contains* the GDF) |
| 310 |
< |
//bad Iritscen, bad! fixed buffers can cause crashes. |
| 311 |
< |
/*char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '"; |
| 312 |
< |
strcat(prefsCommand, fullAEpath.c_str()); |
| 313 |
< |
strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters |
| 314 |
< |
*/ |
| 311 |
> |
string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for Edition/ (Oni wants folder that *contains* the GDF) |
| 312 |
|
string prefsCommand = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '" |
| 313 |
|
+ fullAEpath + "'"; |
| 314 |
|
system(prefsCommand.c_str()); |
| 346 |
|
|
| 347 |
|
if (!file.fail()) |
| 348 |
|
{ |
| 349 |
< |
package = fileToModPackage(file); |
| 350 |
< |
if (package.installerVersion.compare(INSTALLER_VERSION) < 1) // if mod requires newer version of the Installer, we won't add it to the list |
| 349 |
> |
package = fileToModPackage(file, dir_itr->path().filename()); |
| 350 |
> |
|
| 351 |
> |
if (package.installerVersion.compare(gInstallerVersion) < 1) // if mod requires newer version of the Installer, we won't add it to the list |
| 352 |
|
{ |
| 353 |
|
#ifdef WIN32 |
| 354 |
|
if (!package.platform.compare("Windows") || !package.platform.compare("Both")) // don't show package if it's not for the right OS |
| 371 |
|
return packages; |
| 372 |
|
} |
| 373 |
|
|
| 374 |
< |
ModPackage fileToModPackage(fstream &file) |
| 375 |
< |
{ |
| 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 |
< |
*/ |
| 374 |
> |
ModPackage fileToModPackage(fstream &file, string modName) |
| 375 |
> |
{ |
| 376 |
|
ModPackage package; |
| 377 |
< |
string line; |
| 378 |
< |
static string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... |
| 379 |
< |
static string NameOfMod = "NameOfMod"; |
| 380 |
< |
static string ARROW = "->"; |
| 381 |
< |
static string ModString = "ModString"; |
| 382 |
< |
static string Platform = "Platform"; |
| 383 |
< |
static string HasOnis = "HasOnis"; |
| 384 |
< |
static string HasDeltas = "HasDeltas"; |
| 385 |
< |
static string HasBSL = "HasBSL"; |
| 386 |
< |
static string HasDats = "HasDats"; |
| 387 |
< |
static string IsEngine = "IsEngine"; |
| 388 |
< |
static string Readme = "Readme"; |
| 389 |
< |
static string GlobalNeeded = "GlobalNeeded"; |
| 390 |
< |
static string Category = "Category"; |
| 391 |
< |
static string Creator = "Creator"; |
| 377 |
> |
const string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... |
| 378 |
> |
const string NameOfMod = "NameOfMod"; |
| 379 |
> |
const string ARROW = "->"; |
| 380 |
> |
const string ModString = "ModString"; |
| 381 |
> |
const string ModVersion = "ModVersion"; |
| 382 |
> |
const string Platform = "Platform"; |
| 383 |
> |
const string HasOnis = "HasOnis"; |
| 384 |
> |
const string HasDeltas = "HasDeltas"; |
| 385 |
> |
const string HasBSL = "HasBSL"; |
| 386 |
> |
const string HasDats = "HasDats"; |
| 387 |
> |
const string IsEngine = "IsEngine"; |
| 388 |
> |
const string Readme = "Readme"; |
| 389 |
> |
const string GlobalNeeded = "GlobalNeeded"; |
| 390 |
> |
const string Category = "Category"; |
| 391 |
> |
const string Creator = "Creator"; |
| 392 |
|
while (!file.eof()) |
| 393 |
|
{ |
| 394 |
< |
getline(file,line); |
| 395 |
< |
vector<string> tokens; |
| 394 |
> |
string line; |
| 395 |
> |
getline(file, line); |
| 396 |
> |
vector<string> tokens; |
| 397 |
|
vector<string>::iterator iter; |
| 398 |
|
tokenize(line, tokens); |
| 399 |
|
if (tokens.capacity() >= 3) |
| 400 |
|
{ |
| 401 |
+ |
for (int a = 0; a < tokens.size(); a++) |
| 402 |
+ |
StripNewlines(&tokens.at(a)); |
| 403 |
|
iter = tokens.begin(); |
| 404 |
< |
|
| 404 |
> |
|
| 405 |
|
if (!AEInstallVersion.compare(*iter)) |
| 406 |
|
{ |
| 407 |
|
iter++; iter++; |
| 418 |
|
else if (!ModString.compare(*iter)) |
| 419 |
|
{ |
| 420 |
|
iter++; iter++; |
| 421 |
< |
package.modStringName = *iter; |
| 421 |
> |
//package.modStringName = *iter; |
| 422 |
|
iter++; |
| 423 |
|
package.modStringVersion = atof((*iter).c_str()); |
| 424 |
|
} |
| 425 |
+ |
else if (!ModVersion.compare(*iter)) |
| 426 |
+ |
{ |
| 427 |
+ |
iter++; iter++; |
| 428 |
+ |
package.modStringVersion = atof((*iter).c_str()); |
| 429 |
+ |
} |
| 430 |
|
else if (!Platform.compare(*iter)) |
| 431 |
|
{ |
| 432 |
|
iter++; iter++; |
| 440 |
|
else if (!HasBSL.compare(*iter)) |
| 441 |
|
{ |
| 442 |
|
iter++; iter++; |
| 443 |
< |
if (toupper((*iter)[0]) == 'Y' && toupper((*iter)[1]) == 'E' && toupper((*iter)[2]) == 'S') package.hasBSL = true; |
| 443 |
> |
if (boost::iequals(*iter, "Yes")) package.hasBSL = true; |
| 444 |
|
else if (boost::iequals(*iter, "Addon")) package.hasAddon = true; |
| 445 |
|
} |
| 446 |
|
else if (!HasDeltas.compare(*iter)) |
| 493 |
|
} |
| 494 |
|
} |
| 495 |
|
} |
| 496 |
< |
|
| 496 |
> |
package.modStringName = modName; |
| 497 |
|
return package; |
| 498 |
|
} |
| 499 |
|
|
| 565 |
|
|
| 566 |
|
|
| 567 |
|
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
| 568 |
< |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); |
| 568 |
> |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
| 569 |
> |
dir_itr->path().filename() + " "); |
| 570 |
|
|
| 571 |
|
system(importCommand.c_str()); |
| 572 |
|
j++; |
| 593 |
|
else if(splitInstances == false){ |
| 594 |
|
directory_iterator end_iter; |
| 595 |
|
|
| 596 |
< |
for ( directory_iterator dir_itr( vanilla_dir ); |
| 597 |
< |
dir_itr != end_iter; |
| 598 |
< |
++dir_itr ) |
| 599 |
< |
{ |
| 600 |
< |
if ( is_directory( dir_itr->status() ) ) |
| 601 |
< |
{ |
| 602 |
< |
numberOfDats++; |
| 596 |
> |
|
| 597 |
> |
char levelnums[256] = {0}; |
| 598 |
> |
|
| 599 |
> |
|
| 600 |
> |
|
| 601 |
> |
for(int k = 0; k < 256; k++) { |
| 602 |
> |
if( exists( (path)("./VanillaDats/level" + lexical_cast<std::string>(k) + "_final/") ) ) { |
| 603 |
> |
levelnums[k] = 1; |
| 604 |
> |
|
| 605 |
|
} |
| 606 |
|
} |
| 607 |
< |
|
| 607 |
> |
|
| 608 |
> |
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 609 |
> |
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 610 |
> |
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 611 |
> |
for(int k = 0; k < 256; k++) { |
| 612 |
> |
if( globalPackages[j].hasOnis && |
| 613 |
> |
exists( (path)("packages/" + globalPackages[j].modStringName + "/oni/level" + lexical_cast<std::string>(k) + "_final/") ) ) { |
| 614 |
> |
levelnums[k] = 1; |
| 615 |
> |
|
| 616 |
> |
} |
| 617 |
> |
} |
| 618 |
> |
} |
| 619 |
> |
} |
| 620 |
> |
} |
| 621 |
> |
for (int levelnum = 0; levelnum < 256; levelnum++) |
| 622 |
> |
if (levelnums[levelnum]) |
| 623 |
> |
numberOfDats++; |
| 624 |
> |
|
| 625 |
|
out << numberOfDats; |
| 626 |
|
datString = out.str(); |
| 627 |
< |
|
| 628 |
< |
for ( directory_iterator dir_itr( vanilla_dir ); |
| 611 |
< |
dir_itr != end_iter; |
| 612 |
< |
++dir_itr ) |
| 613 |
< |
{ |
| 627 |
> |
|
| 628 |
> |
for(int levelnum = 0; levelnum < 256; levelnum++) { |
| 629 |
|
try |
| 630 |
|
{ |
| 631 |
< |
if ( is_directory( dir_itr->status() ) ) |
| 631 |
> |
if ( levelnums[levelnum] ) |
| 632 |
|
{ |
| 633 |
< |
importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " "; |
| 633 |
> |
importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + "level" + lexical_cast<std::string>(levelnum) + "_Final "; |
| 634 |
|
for (unsigned int i = 0; i < installedMods.size(); ++i) { |
| 635 |
< |
if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename() )) |
| 636 |
< |
importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename(); |
| 635 |
> |
if (exists((path)("packages/" + installedMods[i] + "/oni/level" + lexical_cast<std::string>(levelnum) + "_final") )) |
| 636 |
> |
importCommand += " packages/" + installedMods[i] + "/oni/level" + lexical_cast<std::string>(levelnum) + "_Final"; |
| 637 |
|
} |
| 638 |
< |
importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; |
| 638 |
> |
importCommand += " ../GameDataFolder/level" + lexical_cast<std::string>(levelnum) + "_Final.dat >> Install.log"; |
| 639 |
|
|
| 640 |
|
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
| 641 |
< |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); |
| 641 |
> |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
| 642 |
> |
"level" + lexical_cast<std::string>(levelnum) + "_Final"+ " "); |
| 643 |
|
system(importCommand.c_str()); |
| 644 |
|
j++; |
| 645 |
|
} |
| 659 |
|
vector<string> skippedfolders; |
| 660 |
|
|
| 661 |
|
ofstream BSLlog("BSL.log"); |
| 662 |
+ |
if(!exists("../GameDataFolder/BSLBackup/")) { |
| 663 |
+ |
create_directory("../GameDataFolder/BSLBackup/"); |
| 664 |
+ |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 665 |
+ |
} |
| 666 |
+ |
|
| 667 |
|
for ( directory_iterator dir_itr( "../GameDataFolder/IGMD/" ), end_itr; |
| 668 |
|
dir_itr != end_itr; |
| 669 |
|
++dir_itr ) { |
| 676 |
|
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 677 |
|
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 678 |
|
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 679 |
< |
if(!(globalPackages[j].hasAddon || globalPackages[j].hasBSL)) break; //skip non-BSL |
| 679 |
> |
if(!globalPackages[j].hasBSL) break; //skip non-BSL |
| 680 |
|
if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { |
| 681 |
|
copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); |
| 682 |
|
BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; |
| 685 |
|
} |
| 686 |
|
} |
| 687 |
|
|
| 688 |
+ |
|
| 689 |
+ |
|
| 690 |
|
ModPackage emptyPackage; |
| 691 |
|
emptyPackage.modStringName = "VanillaBSL"; |
| 692 |
|
emptyPackage.hasBSL = 1; |
| 693 |
|
copyBSL("packages/VanillaBSL/IGMD", BSLfolders, emptyPackage); |
| 694 |
|
BSLlog.close(); |
| 695 |
< |
|
| 695 |
> |
|
| 696 |
> |
for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) |
| 697 |
> |
for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages |
| 698 |
> |
if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it |
| 699 |
> |
if(!globalPackages[j].hasAddon) break; //skip non-BSL |
| 700 |
> |
if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { |
| 701 |
> |
copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); |
| 702 |
> |
BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; |
| 703 |
> |
} |
| 704 |
> |
} |
| 705 |
> |
} |
| 706 |
> |
} |
| 707 |
> |
|
| 708 |
|
logfile << "Writing config file"; |
| 709 |
|
writeInstalledMods(installedMods); |
| 710 |
|
setProgressBar(1000); |
| 735 |
|
|
| 736 |
|
void copyBSL(string copypath, vector<string>& BSLfolders, ModPackage pkg) |
| 737 |
|
{ |
| 738 |
< |
ofstream BSLlog("BSL2.log", ios::app ); |
| 738 |
> |
ofstream BSLlog("BSL.log", ios::app ); |
| 739 |
|
|
| 740 |
|
try { |
| 741 |
|
for ( directory_iterator dir_itr( copypath ), end_itr; |
| 745 |
|
if ( is_directory( dir_itr->path() ) && dir_itr->path().string() != ".svn" ) { |
| 746 |
|
BSLlog << "Testing " << dir_itr->path().string() << " HasBSL: " << pkg.hasBSL << " HasAddon: " << pkg.hasAddon << "\n"; |
| 747 |
|
int skip_folder = 0; |
| 748 |
< |
|
| 749 |
< |
for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders |
| 750 |
< |
BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; |
| 751 |
< |
if(dir_itr->path().filename() == BSLfolders[k]) { |
| 752 |
< |
skip_folder = 1; |
| 753 |
< |
BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; |
| 754 |
< |
break; |
| 748 |
> |
if(!pkg.hasAddon) { |
| 749 |
> |
for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders |
| 750 |
> |
BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; |
| 751 |
> |
if(dir_itr->path().filename() == BSLfolders[k]) { |
| 752 |
> |
skip_folder = 1; |
| 753 |
> |
BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; |
| 754 |
> |
break; |
| 755 |
> |
} |
| 756 |
|
} |
| 757 |
|
} |
| 758 |
|
if (!skip_folder && !exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/ignore.txt")) { |
| 759 |
< |
remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); |
| 759 |
> |
if(!pkg.hasAddon) remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); |
| 760 |
|
Sleep(100); |
| 761 |
|
create_directory( "../GameDataFolder/IGMD/" + dir_itr->path().filename()); |
| 762 |
|
BSLlog << "Copied " << dir_itr->path().string() << " in " << pkg.modStringName << "!\n"; |
| 764 |
|
bsl_itr != end_itr; |
| 765 |
|
bsl_itr++ ) { |
| 766 |
|
if ( bsl_itr->path().extension() == ".bsl" ) { |
| 767 |
+ |
if(exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename())) |
| 768 |
+ |
remove("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 769 |
|
copy_file(bsl_itr->path(), "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 770 |
|
} |
| 771 |
|
} |
| 772 |
< |
BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon |
| 773 |
< |
BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; |
| 772 |
> |
if( !pkg.hasAddon ) { |
| 773 |
> |
BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon |
| 774 |
> |
BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; |
| 775 |
> |
} |
| 776 |
|
} |
| 777 |
|
} |
| 778 |
|
} |
| 848 |
|
| Installer to be replaced (when the new Installer | |
| 849 |
|
| launches, this function will be called again but will | |
| 850 |
|
| return UPDATE_SIMP_AVAIL or UPDATE_GLOB_AVAIL) | |
| 851 |
+ |
| UPDATE_PKG_AVAIL -- A newer version of individual package(s) is available | |
| 852 |
|
\* UPDATE_CONT_UPD -- Currently unused */ |
| 853 |
|
int GetUpdateStatus(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) |
| 854 |
|
{ |
| 878 |
|
return UPDATE_LOG_READ_ERR; |
| 879 |
|
} |
| 880 |
|
|
| 881 |
< |
// Is there an update folder, and is it a monthly release or a patch? |
| 881 |
> |
// Is there an update in the updates/ folder, and is it a monthly release or a patch? |
| 882 |
|
bool firstParty = 0; |
| 883 |
+ |
// First create the folder if it's missing, so users are never left wondering where updates are supposed to be put |
| 884 |
+ |
if (!exists("../updates")) |
| 885 |
+ |
create_directory("../updates"); |
| 886 |
|
if (exists("../updates/Edition")) |
| 887 |
|
{ |
| 888 |
|
firstParty = 1; |
| 943 |
|
else if (readingInstallerVersion && tokens.capacity() >= 3) |
| 944 |
|
{ |
| 945 |
|
readingInstallerVersion = false; |
| 946 |
< |
string installerVersion = INSTALLER_VERSION; |
| 903 |
< |
if (installerVersion.compare(*iter)) // then the shell script-powered replacement failed |
| 946 |
> |
if (gInstallerVersion.compare(*iter)) // then the shell script-powered replacement failed |
| 947 |
|
return UPDATE_INST_REPL_ERR; |
| 948 |
|
else |
| 949 |
|
{ |
| 957 |
|
// Write over old log with updated information |
| 958 |
|
ptime startTime(second_clock::local_time()); |
| 959 |
|
string strStartTime = to_simple_string(startTime); |
| 960 |
< |
string newUpdateLine = installerVersion + " on " + strStartTime; |
| 960 |
> |
string newUpdateLine = gInstallerVersion + " on " + strStartTime; |
| 961 |
|
for (int a = 0; a < lines.capacity() - 2; a++) // if there were even lines in the log before this at all |
| 962 |
|
{ |
| 963 |
|
newUpdateLog << lines[a].c_str(); |
| 965 |
|
} |
| 966 |
|
newUpdateLog << "Installer was updated to:\n"; |
| 967 |
|
newUpdateLog << newUpdateLine.c_str(); |
| 968 |
< |
*installerJustUpdated = true; // this value is indirectly returned to AEInstallerAp::OnInit() |
| 968 |
> |
*installerJustUpdated = true; // this value is indirectly returned to AEInstallerApp::OnInit() |
| 969 |
|
doneReadingFile = true; |
| 970 |
|
newUpdateLog.close(); |
| 971 |
|
newUpdateLog.clear(); |
| 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 |
|
{ |
| 946 |
– |
if (!strEUFN.compare("Edition-patch")) // if update is a patch... |
| 947 |
– |
{ |
| 948 |
– |
if (currentAE->AEVersion.compare(updateAE->AEVersion.substr(0, updateAE->AEVersion.length() - 1))) // ...is it for a different month? |
| 949 |
– |
return UPDATE_MNTH_REQD_ERR; |
| 950 |
– |
} |
| 989 |
|
string strNewInstallerPath = "../updates/" + strEUFN + "/install/" + strInstallerName; |
| 990 |
< |
string installerVersion = INSTALLER_VERSION; |
| 953 |
< |
if (updateAE->InstallerVersion.compare(installerVersion) >= 1) |
| 990 |
> |
if (updateAE->InstallerVersion.compare(gInstallerVersion) >= 1) |
| 991 |
|
{ |
| 992 |
|
if (exists(strNewInstallerPath)) |
| 993 |
|
return UPDATE_INST_AVAIL; |
| 997 |
|
else |
| 998 |
|
return UPDATE_SIMP_AVAIL; |
| 999 |
|
} |
| 1000 |
+ |
else |
| 1001 |
+ |
return UPDATE_MNTH_REQD_ERR; |
| 1002 |
|
} |
| 1003 |
< |
try { |
| 965 |
< |
directory_iterator end; |
| 966 |
< |
if(exists("../updates")){ |
| 967 |
< |
for ( directory_iterator install_iter( "../updates" ); |
| 968 |
< |
install_iter != end; |
| 969 |
< |
++install_iter ) |
| 1003 |
> |
try |
| 1004 |
|
{ |
| 1005 |
< |
|
| 1006 |
< |
ModPackage installedPackage, updatePackage; |
| 1007 |
< |
if ( is_directory( install_iter->path() ) && exists( install_iter->path().string() + "/Mod_Info.cfg" ) ) { |
| 1008 |
< |
fstream file; |
| 975 |
< |
file.open( (install_iter->path().string() + "/Mod_Info.cfg").c_str()); |
| 976 |
< |
if (!file.fail()) |
| 977 |
< |
{ |
| 978 |
< |
ModPackage updatePackage = fileToModPackage(file); |
| 979 |
< |
} |
| 980 |
< |
else |
| 981 |
< |
{ |
| 982 |
< |
file.close(); |
| 983 |
< |
continue; |
| 984 |
< |
} |
| 985 |
< |
if(!exists("packages" + install_iter->path().filename() + "/Mod_Info.cfg")); |
| 986 |
< |
file.close(); |
| 987 |
< |
file.open( ("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); |
| 988 |
< |
if (!file.fail()) |
| 989 |
< |
{ |
| 990 |
< |
ModPackage installedPackage = fileToModPackage(file); |
| 991 |
< |
} |
| 992 |
< |
else |
| 1005 |
> |
directory_iterator end; |
| 1006 |
> |
if (exists("../updates")) |
| 1007 |
> |
{ |
| 1008 |
> |
for (directory_iterator install_iter("../updates"); install_iter != end; ++install_iter) |
| 1009 |
|
{ |
| 1010 |
< |
file.close(); |
| 1011 |
< |
return UPDATE_THIRD_PARTY; |
| 1012 |
< |
} |
| 1013 |
< |
file.close(); |
| 1014 |
< |
if(updatePackage.modStringVersion > installedPackage.modStringVersion) { |
| 1015 |
< |
return UPDATE_THIRD_PARTY; |
| 1010 |
> |
ModPackage installedPackage, updatePackage; |
| 1011 |
> |
if (is_directory(install_iter->path()) && exists(install_iter->path().string() + "/Mod_Info.cfg")) |
| 1012 |
> |
{ |
| 1013 |
> |
fstream file; |
| 1014 |
> |
file.open((install_iter->path().string() + "/Mod_Info.cfg").c_str()); |
| 1015 |
> |
if (!file.fail()) |
| 1016 |
> |
updatePackage = fileToModPackage(file, install_iter->path().filename()); |
| 1017 |
> |
else |
| 1018 |
> |
{ |
| 1019 |
> |
file.close(); |
| 1020 |
> |
continue; |
| 1021 |
> |
} |
| 1022 |
> |
if (exists("packages/" + install_iter->path().filename() + "/Mod_Info.cfg")) |
| 1023 |
> |
{ |
| 1024 |
> |
file.close(); |
| 1025 |
> |
file.clear(); |
| 1026 |
> |
file.open(("packages/" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); |
| 1027 |
> |
if (!file.fail()) |
| 1028 |
> |
installedPackage = fileToModPackage(file, install_iter->path().filename()); |
| 1029 |
> |
file.close(); |
| 1030 |
> |
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1031 |
> |
{ |
| 1032 |
> |
if (updatePackage.installerVersion.compare(gInstallerVersion) < 1) |
| 1033 |
> |
return UPDATE_PKG_AVAIL; |
| 1034 |
> |
} |
| 1035 |
> |
} |
| 1036 |
> |
else |
| 1037 |
> |
{ |
| 1038 |
> |
file.close(); |
| 1039 |
> |
return UPDATE_PKG_AVAIL; |
| 1040 |
> |
} |
| 1041 |
> |
} |
| 1042 |
|
} |
| 1001 |
– |
|
| 1043 |
|
} |
| 1003 |
– |
} |
| 1004 |
– |
|
| 1005 |
– |
} |
| 1044 |
|
} |
| 1045 |
|
catch (exception & ex) { |
| 1046 |
|
// setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1047 |
|
} |
| 1010 |
– |
|
| 1048 |
|
|
| 1049 |
|
return UPDATE_NO_UPD_AVAIL; |
| 1050 |
|
} |
| 1059 |
|
string strDaodanVersion = "Daodan_Version"; |
| 1060 |
|
string strOniSplitVersion = "OniSplit_Version"; |
| 1061 |
|
string strGUIWinVersion = "GUI_Win_Version"; |
| 1062 |
< |
string strGUIMacVersion = "GUI_Mac_Version"; |
| 1062 |
> |
string strGUIMacVersion = "GUI_Mac_Version"; |
| 1063 |
|
string strReglobalize = "Reglobalize"; |
| 1064 |
|
string strDeleteList = "Delete_List"; |
| 1065 |
|
string strArrow = "->"; |
| 1271 |
|
|
| 1272 |
|
string popenCommand = "../updates/" + strEUFN + "/install/"; |
| 1273 |
|
#ifdef WIN32 |
| 1237 |
– |
// TODO: Fill in Windows equivalent of code below :-3 |
| 1274 |
|
popenCommand = "replace_installer.bat"; |
| 1275 |
|
#else |
| 1276 |
|
// We can't just use '~' to mean "the home directory" because we need to check the path in C... |
| 1300 |
|
#endif |
| 1301 |
|
return true; // returning 'true' tells the Installer to quit itself ASAP so it can be replaced by the process that is now running |
| 1302 |
|
} |
| 1267 |
– |
//strPathToEUFNPackages |
| 1268 |
– |
|
| 1269 |
– |
void CrawlPackages(string pathToUpdate, string strPathToPackages) { |
| 1270 |
– |
try{ |
| 1271 |
– |
directory_iterator end; |
| 1272 |
– |
for ( directory_iterator install_iter( pathToUpdate ); |
| 1273 |
– |
install_iter != end; |
| 1274 |
– |
++install_iter ) |
| 1275 |
– |
{ |
| 1276 |
– |
|
| 1277 |
– |
ModPackage installedPackage, updatePackage; |
| 1278 |
– |
string updateStr = install_iter->path().string() + "/Mod_Info.cfg"; |
| 1279 |
– |
if ( !boost::iequals(install_iter->path().filename(),"Edition") |
| 1280 |
– |
&& !boost::iequals(install_iter->path().filename(),"Edition-patch") |
| 1281 |
– |
&& is_directory( install_iter->path() ) |
| 1282 |
– |
&& exists( install_iter->path().string() + "/Mod_Info.cfg" ) ) |
| 1283 |
– |
{ |
| 1284 |
– |
bool update = 0; |
| 1285 |
– |
fstream file; |
| 1286 |
– |
file.open( (install_iter->path().string() + "/Mod_Info.cfg").c_str()); |
| 1287 |
– |
if (!file.fail()) |
| 1288 |
– |
{ |
| 1289 |
– |
updatePackage = fileToModPackage(file); |
| 1290 |
– |
} |
| 1291 |
– |
else |
| 1292 |
– |
{ |
| 1293 |
– |
file.close(); |
| 1294 |
– |
continue; |
| 1295 |
– |
} |
| 1296 |
– |
if(!exists(strPathToPackages + "/" + install_iter->path().filename() + "/Mod_Info.cfg")); |
| 1297 |
– |
file.close(); |
| 1298 |
– |
file.clear(); |
| 1299 |
– |
file.open((strPathToPackages + "/" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); |
| 1300 |
– |
if (!file.fail()) |
| 1301 |
– |
{ |
| 1302 |
– |
installedPackage = fileToModPackage(file); |
| 1303 |
– |
file.close(); |
| 1304 |
– |
if(updatePackage.modStringVersion > installedPackage.modStringVersion) { |
| 1305 |
– |
remove_all((path)(strPathToPackages + "/" + installedPackage.modStringName)); |
| 1306 |
– |
update = 1; |
| 1307 |
– |
} |
| 1308 |
– |
} |
| 1309 |
– |
else |
| 1310 |
– |
{ |
| 1311 |
– |
file.close(); |
| 1312 |
– |
update = 1; |
| 1313 |
– |
} |
| 1314 |
– |
file.close(); |
| 1315 |
– |
|
| 1316 |
– |
if(update) { |
| 1317 |
– |
rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); |
| 1318 |
– |
|
| 1319 |
– |
} |
| 1320 |
– |
} |
| 1321 |
– |
} |
| 1322 |
– |
} |
| 1323 |
– |
catch (exception & ex) { |
| 1324 |
– |
// ex.what(); |
| 1325 |
– |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1326 |
– |
} |
| 1327 |
– |
} |
| 1328 |
– |
|
| 1329 |
– |
|
| 1330 |
– |
bool ProcessThirdPartyUpdates() { |
| 1331 |
– |
CrawlPackages( "../updates", "./packages"); |
| 1332 |
– |
return true; |
| 1333 |
– |
// globalPackages = getPackages(); |
| 1334 |
– |
// refreshMods(globalInstalledMods); |
| 1335 |
– |
} |
| 1336 |
– |
|
| 1303 |
|
|
| 1304 |
|
bool ProcessAEUpdate(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) |
| 1305 |
|
{ |
| 1306 |
+ |
try { |
| 1307 |
|
fstream file; |
| 1308 |
|
string line; |
| 1309 |
|
vector<string> tokens, updateStarted; |
| 1323 |
|
string strOniApp = "Oni.exe"; |
| 1324 |
|
#else |
| 1325 |
|
string strOniApp = "Oni.app"; |
| 1359 |
– |
#endif |
| 1326 |
|
bool needNewTrashDir = false; |
| 1327 |
+ |
#endif |
| 1328 |
+ |
|
| 1329 |
|
bool readingVerAndDate = false; |
| 1330 |
|
|
| 1363 |
– |
// TODO: Fill in Windows equivalent of code below |
| 1331 |
|
#ifdef WIN32 |
| 1332 |
< |
string strTrashDir = "Trash\\"; |
| 1332 |
> |
//remove readonly attrib from files. |
| 1333 |
> |
setStatusArea("Removing readonly attribute..."); |
| 1334 |
> |
system("attrib -r ./* /s"); |
| 1335 |
> |
system("attrib -r ../Oni.exe /s"); |
| 1336 |
> |
system("attrib -r ../binkw32.dll /s"); |
| 1337 |
> |
|
| 1338 |
|
#else |
| 1339 |
|
FILE *fUserName = NULL; |
| 1340 |
|
char chrUserName[32]; |
| 1369 |
|
if (readingVerAndDate && tokens.capacity() >= 3) |
| 1370 |
|
tokenize(tokens[2], updateStarted, "-"); |
| 1371 |
|
} |
| 1372 |
+ |
#ifndef WIN32 |
| 1373 |
|
if (updateStarted.capacity() < 3) |
| 1374 |
|
needNewTrashDir = true; |
| 1375 |
|
else |
| 1379 |
|
if (!exists(strTrashDir)) |
| 1380 |
|
needNewTrashDir = true; |
| 1381 |
|
} |
| 1382 |
+ |
#endif |
| 1383 |
|
} |
| 1384 |
|
#ifndef WIN32 |
| 1385 |
|
if (!*installerJustUpdated || needNewTrashDir) // prepare a new directory for deleted files to go to |
| 1396 |
|
// Special code to replace our special files -- the Oni app, OniSplit, the Daodan DLL, and the GUI for OniSplit |
| 1397 |
|
if (exists(strPathToEUFN + strOniApp)) |
| 1398 |
|
{ |
| 1399 |
< |
if (exists(strOniApp)) |
| 1400 |
< |
rename((path)strOniApp, (path)(strTrashDir + strOniApp)); |
| 1401 |
< |
rename((path)(strPathToEUFN + strOniApp), (path)strOniApp); |
| 1399 |
> |
if (exists("../" + strOniApp)) |
| 1400 |
> |
#ifdef WIN32 |
| 1401 |
> |
remove((path)("../" + strOniApp)); |
| 1402 |
> |
#else |
| 1403 |
> |
rename((path)("../" + strOniApp), (path)(strTrashDir + strOniApp)); |
| 1404 |
> |
#endif |
| 1405 |
> |
rename((path)(strPathToEUFN + strOniApp), (path)("../" + strOniApp)); |
| 1406 |
|
} |
| 1407 |
|
if (updateAE->OniSplitVersion.compare(currentAE->OniSplitVersion) >= 1) |
| 1408 |
|
{ |
| 1409 |
|
if (exists(strPathToEUFNInstall + strOniSplit)) |
| 1410 |
|
{ |
| 1411 |
|
if (exists(strOniSplit)) |
| 1412 |
+ |
#ifdef WIN32 |
| 1413 |
+ |
remove((path)strOniSplit); |
| 1414 |
+ |
#else |
| 1415 |
|
rename((path)strOniSplit, (path)(strTrashDir + strOniSplit)); |
| 1416 |
+ |
#endif |
| 1417 |
|
rename((path)(strPathToEUFNInstall + strOniSplit), (path)strOniSplit); |
| 1418 |
|
} |
| 1419 |
|
} |
| 1423 |
|
if (exists(strPathToEUFN + strDaodan)) |
| 1424 |
|
{ |
| 1425 |
|
if (exists(("../" + strDaodan))) |
| 1426 |
< |
rename((path)("../" + strDaodan), (path)(strTrashDir + strDaodan)); |
| 1426 |
> |
remove((path)("../" + strDaodan)); |
| 1427 |
|
rename((path)(strPathToEUFN + strDaodan), (path)("../" + strDaodan)); |
| 1428 |
|
} |
| 1429 |
|
} |
| 1432 |
|
if (exists(strPathToEUFNInstall + strWinGUI)) |
| 1433 |
|
{ |
| 1434 |
|
if (exists((path)strWinGUI)) |
| 1435 |
< |
rename((path)strWinGUI, (path)(strTrashDir + strWinGUI)); |
| 1435 |
> |
remove((path)strWinGUI); |
| 1436 |
|
if (exists(strWinGUILang)) |
| 1437 |
< |
rename((path)strWinGUILang, (path)(strTrashDir + strWinGUILang)); |
| 1437 |
> |
remove((path)strWinGUILang); |
| 1438 |
|
rename((path)(strPathToEUFNInstall + strWinGUI), (path)strWinGUI); |
| 1439 |
|
rename((path)(strPathToEUFNInstall + strWinGUILang), (path)strWinGUILang); |
| 1440 |
|
} |
| 1467 |
|
while (curPos != string::npos && curPos < thePath.size()) |
| 1468 |
|
{ |
| 1469 |
|
aParentPath = aParentPath + thePath.substr(lastPos, curPos - lastPos); |
| 1470 |
+ |
#ifndef WIN32 |
| 1471 |
|
if (!exists(strTrashDir + aParentPath)) |
| 1472 |
|
create_directory(strTrashDir + aParentPath); |
| 1473 |
+ |
#endif |
| 1474 |
|
lastPos = curPos + 1; |
| 1475 |
|
curPos = thePath.find("/", lastPos); |
| 1476 |
|
aParentPath = aParentPath + "/"; |
| 1478 |
|
#ifndef WIN32 |
| 1479 |
|
rename((path)("../" + thePath), (path)(strTrashDir + thePath)); |
| 1480 |
|
#else |
| 1481 |
< |
remove((path)("../" + thePath)); |
| 1481 |
> |
remove_all((path)("../" + thePath)); |
| 1482 |
|
#endif |
| 1483 |
|
} |
| 1484 |
|
} |
| 1485 |
|
|
| 1486 |
< |
CrawlPackages( strPathToEUFNPackages, strPathToPackages); |
| 1486 |
> |
ProcessPackageUpdates(strPathToEUFNPackages, strPathToPackages); |
| 1487 |
|
|
| 1488 |
< |
// 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... |
| 1489 |
< |
// ...and folders which do not exist in the current AE will be created there |
| 1490 |
< |
vector<string> foldersToMake, filesToMove; |
| 1491 |
< |
string thePath; |
| 1488 |
> |
// 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... |
| 1489 |
> |
// ...create_directories() function |
| 1490 |
> |
string strPath; |
| 1491 |
> |
path thePath; |
| 1492 |
|
for (recursive_directory_iterator dir_itr(strPathToEUFNPackages + strGlobalize), end_itr; dir_itr != end_itr; ++dir_itr) |
| 1493 |
|
{ |
| 1494 |
< |
thePath = dir_itr->path().string(); |
| 1495 |
< |
MakePathLocalToGlobalize(&thePath); |
| 1494 |
> |
strPath = dir_itr->path().string(); |
| 1495 |
> |
MakePathLocalToGlobalize(&strPath); |
| 1496 |
> |
thePath = (path)strPath; |
| 1497 |
|
if (is_regular_file(dir_itr->status())) |
| 1498 |
|
{ |
| 1499 |
< |
if (dir_itr->filename().at(0) != '.') // skip over dot-files, which are invisible in Unix |
| 1500 |
< |
filesToMove.push_back(thePath); |
| 1501 |
< |
} |
| 1502 |
< |
else if (is_directory(dir_itr->status())) |
| 1503 |
< |
{ |
| 1504 |
< |
if (!exists(strPathToPackages + strGlobalize + thePath)) |
| 1505 |
< |
foldersToMake.push_back(thePath); |
| 1499 |
> |
if (thePath.filename().at(0) != '.') // skip over dot-files, which are invisible in Unix |
| 1500 |
> |
{ |
| 1501 |
> |
if (exists(strPathToPackages + strGlobalize + strPath)) |
| 1502 |
> |
{ |
| 1503 |
> |
#ifdef WIN32 |
| 1504 |
> |
remove((path)(strPathToPackages + strGlobalize + strPath)); |
| 1505 |
> |
#else |
| 1506 |
> |
create_directories((path)(strTrashDir + thePath.parent_path().string())); |
| 1507 |
> |
rename((path)(strPathToPackages + strGlobalize + strPath), (path)(strTrashDir + strPath)); |
| 1508 |
> |
#endif |
| 1509 |
> |
rename((path)(strPathToEUFNPackages + strGlobalize + strPath), (path)(strPathToPackages + strGlobalize + strPath)); |
| 1510 |
> |
} |
| 1511 |
> |
else |
| 1512 |
> |
{ |
| 1513 |
> |
int slashLoc = 0; |
| 1514 |
> |
slashLoc = strPath.find("/", 0); |
| 1515 |
> |
if (slashLoc != string::npos) // then path contains slashes, so we need to make sure its parents' paths exist before moving it |
| 1516 |
> |
create_directories((path)(strPathToPackages + strGlobalize + thePath.parent_path().string())); |
| 1517 |
> |
rename((path)(strPathToEUFNPackages + strGlobalize + strPath), (path)(strPathToPackages + strGlobalize + strPath)); |
| 1518 |
> |
} |
| 1519 |
> |
} |
| 1520 |
|
} |
| 1521 |
|
} |
| 1523 |
– |
// Sort the foldersToMake strings by length, which is a fast solution to the problem of "How do we make sure we create folder 'parent/'... |
| 1524 |
– |
// ...before folder 'parent/child/'"? |
| 1525 |
– |
sort(foldersToMake.begin(), foldersToMake.end(), SortBySize); // SortBySize is a custom comparison function found later in this source file |
| 1526 |
– |
// First make the folders that don't exist in the current AE, so all the files have a place to go |
| 1527 |
– |
for (vector<string>::iterator iter = foldersToMake.begin(); iter != foldersToMake.end(); iter++) |
| 1528 |
– |
{ |
| 1529 |
– |
create_directory(strPathToPackages + strGlobalize + *iter); |
| 1530 |
– |
} |
| 1531 |
– |
for (vector<string>::iterator iter = filesToMove.begin(); iter != filesToMove.end(); iter++) |
| 1532 |
– |
{ |
| 1533 |
– |
if (exists(strPathToPackages + strGlobalize + *iter)) |
| 1534 |
– |
rename((path)(strPathToPackages + strGlobalize + *iter), (path)(strTrashDir + *iter)); |
| 1535 |
– |
rename((path)(strPathToEUFNPackages + strGlobalize + *iter), (path)(strPathToPackages + strGlobalize + *iter)); |
| 1536 |
– |
} |
| 1522 |
|
|
| 1523 |
|
// Clean up after ourselves, trashing any packages or programs in the update package that are not newer than the current AE |
| 1524 |
+ |
#ifdef WIN32 |
| 1525 |
+ |
remove_all((path)strPathToEUFN); |
| 1526 |
+ |
#else |
| 1527 |
|
create_directory(strTrashDir + "Unneeded update files"); |
| 1528 |
|
rename((path)strPathToEUFN, (path)(strTrashDir + "Unneeded update files/" + strEUFN)); |
| 1529 |
< |
|
| 1529 |
> |
#endif |
| 1530 |
|
// Write to log that we are finished with update |
| 1531 |
|
ptime end_time(second_clock::local_time()); |
| 1532 |
|
string progressMsg2 = "Edition was updated to:\n" + |
| 1544 |
|
CheckForGlobalization(true); // the 'true' value forces re-globalization |
| 1545 |
|
|
| 1546 |
|
globalPackages = getPackages(); // refresh the list in memory |
| 1547 |
< |
// TODO: Refresh the packages list in the window |
| 1548 |
< |
|
| 1547 |
> |
wxCommandEvent e; |
| 1548 |
> |
TheWindow->OnRefreshButtonClick( e ); |
| 1549 |
|
return true; |
| 1550 |
+ |
} |
| 1551 |
+ |
catch (exception & ex) |
| 1552 |
+ |
{ |
| 1553 |
+ |
wxMessageDialog* DotNetDialogOfDeath = |
| 1554 |
+ |
new wxMessageDialog(TheWindow, ex.what(), "AE Installer Alert", |
| 1555 |
+ |
wxICON_EXCLAMATION , wxDefaultPosition); |
| 1556 |
+ |
|
| 1557 |
+ |
DotNetDialogOfDeath->ShowModal(); |
| 1558 |
+ |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1559 |
+ |
return false; |
| 1560 |
+ |
} |
| 1561 |
+ |
} |
| 1562 |
+ |
|
| 1563 |
+ |
void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages) |
| 1564 |
+ |
{ |
| 1565 |
+ |
ptime startTime(second_clock::local_time()); |
| 1566 |
+ |
#ifdef WIN32 |
| 1567 |
+ |
string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted |
| 1568 |
+ |
#else |
| 1569 |
+ |
FILE *fUserName = NULL; |
| 1570 |
+ |
char chrUserName[32]; |
| 1571 |
+ |
fUserName = popen("whoami", "r"); |
| 1572 |
+ |
fgets(chrUserName, sizeof(chrUserName), fUserName); |
| 1573 |
+ |
pclose(fUserName); |
| 1574 |
+ |
string strUserName = (string)chrUserName; // stringsblaaarrrgggghhhh |
| 1575 |
+ |
int endOfName = strUserName.find("\n", 0); |
| 1576 |
+ |
string strTrashDir = "/Users/" + strUserName.substr(0, endOfName) + "/.Trash/"; |
| 1577 |
+ |
bool needNewTrashDir = true; |
| 1578 |
+ |
tm tmStartTime = to_tm(startTime); |
| 1579 |
+ |
#endif |
| 1580 |
+ |
|
| 1581 |
+ |
try |
| 1582 |
+ |
{ |
| 1583 |
+ |
directory_iterator end; |
| 1584 |
+ |
for (directory_iterator update_iter(pathToUpdate); update_iter != end; ++update_iter) |
| 1585 |
+ |
{ |
| 1586 |
+ |
ModPackage installedPackage, updatePackage; |
| 1587 |
+ |
string updtPath = update_iter->path().string(); |
| 1588 |
+ |
string updtFolder = update_iter->path().filename(); |
| 1589 |
+ |
string updtModInfo = updtPath + "/Mod_Info.cfg"; |
| 1590 |
+ |
string instModInfo = strPathToPackages + "/" + updtFolder + "/Mod_Info.cfg"; |
| 1591 |
+ |
if (!boost::iequals(updtFolder, "Edition") |
| 1592 |
+ |
&& !boost::iequals(updtFolder, "Edition-patch") |
| 1593 |
+ |
&& is_directory(update_iter->path()) |
| 1594 |
+ |
&& exists(updtModInfo)) |
| 1595 |
+ |
{ |
| 1596 |
+ |
fstream file; |
| 1597 |
+ |
file.open((updtModInfo).c_str()); |
| 1598 |
+ |
if (!file.fail()) |
| 1599 |
+ |
updatePackage = fileToModPackage(file, updtFolder); |
| 1600 |
+ |
else |
| 1601 |
+ |
{ |
| 1602 |
+ |
file.close(); |
| 1603 |
+ |
continue; |
| 1604 |
+ |
} |
| 1605 |
+ |
if (exists(instModInfo)) |
| 1606 |
+ |
{ |
| 1607 |
+ |
file.close(); |
| 1608 |
+ |
file.clear(); |
| 1609 |
+ |
file.open(instModInfo.c_str()); |
| 1610 |
+ |
if (!file.fail()) |
| 1611 |
+ |
{ |
| 1612 |
+ |
installedPackage = fileToModPackage(file, updtFolder); |
| 1613 |
+ |
} |
| 1614 |
+ |
file.close(); |
| 1615 |
+ |
} |
| 1616 |
+ |
file.close(); |
| 1617 |
+ |
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1618 |
+ |
{ |
| 1619 |
+ |
if (updatePackage.installerVersion.compare(gInstallerVersion) < 1) |
| 1620 |
+ |
{ |
| 1621 |
+ |
if(exists(strPathToPackages + "/" + updatePackage.modStringName)) { |
| 1622 |
+ |
#ifdef WIN32 |
| 1623 |
+ |
remove_all((path)(strPathToPackages + "/" + updatePackage.modStringName)); |
| 1624 |
+ |
#else |
| 1625 |
+ |
if (needNewTrashDir) |
| 1626 |
+ |
{ |
| 1627 |
+ |
strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast<string>(tmStartTime.tm_hour) + "-" + |
| 1628 |
+ |
boost::lexical_cast<string>(tmStartTime.tm_min) + "-" + boost::lexical_cast<string>(tmStartTime.tm_sec) + "/"; |
| 1629 |
+ |
create_directory(strTrashDir); |
| 1630 |
+ |
needNewTrashDir = false; |
| 1631 |
+ |
} |
| 1632 |
+ |
rename((path)(strPathToPackages + "/" + updatePackage.modStringName), (path)(strTrashDir + updatePackage.modStringName)); |
| 1633 |
+ |
#endif |
| 1634 |
+ |
} |
| 1635 |
+ |
rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); |
| 1636 |
+ |
} |
| 1637 |
+ |
} |
| 1638 |
+ |
} |
| 1639 |
+ |
} |
| 1640 |
+ |
} |
| 1641 |
+ |
catch (exception & ex) |
| 1642 |
+ |
{ |
| 1643 |
+ |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1644 |
+ |
} |
| 1645 |
+ |
wxCommandEvent e; |
| 1646 |
+ |
TheWindow->OnRefreshButtonClick( e ); |
| 1647 |
|
} |
| 1648 |
|
|
| 1649 |
|
/* MakePathLocalToGlobalize is a function used once by ProcessAEUpdate() that takes a file in an \ |
| 1689 |
|
|
| 1690 |
|
/* StripNewlines() gets rids of any linebreaks that come from text returned by getline(); \ |
| 1691 |
|
| getline() should be stripping those out, but Windows CR/LF files seem to be sneaking | |
| 1692 |
< |
\ some extra return characters into strings in the ReadInstallInfoCfg() function. */ |
| 1692 |
> |
\ some extra return characters into strings. */ |
| 1693 |
|
void StripNewlines(string *theLine) |
| 1694 |
|
{ |
| 1695 |
|
int deleteFromHere = 0; |
| 1742 |
|
|
| 1743 |
|
} |
| 1744 |
|
else if(from_ph.filename() != ".svn") |
| 1745 |
< |
{ |
| 1746 |
< |
path destination; |
| 1747 |
< |
if(!exists(to_ph)) |
| 1748 |
< |
{ |
| 1749 |
< |
destination=to_ph; |
| 1750 |
< |
} |
| 1751 |
< |
else |
| 1752 |
< |
{ |
| 1753 |
< |
destination=to_ph/from_ph.filename(); |
| 1754 |
< |
} |
| 1745 |
> |
{ |
| 1746 |
> |
path destination; |
| 1747 |
> |
if(!exists(to_ph)) |
| 1748 |
> |
{ |
| 1749 |
> |
destination=to_ph; |
| 1750 |
> |
} |
| 1751 |
> |
else |
| 1752 |
> |
{ |
| 1753 |
> |
destination=to_ph/from_ph.filename(); |
| 1754 |
> |
} |
| 1755 |
|
|
| 1756 |
< |
for(directory_iterator i(from_ph); i!=directory_iterator(); ++i) |
| 1756 |
> |
for(directory_iterator i(from_ph); i!=directory_iterator(); ++i) |
| 1757 |
|
{ |
| 1758 |
|
//the idiot who coded this in the first place (not me) |
| 1759 |
|
//forgot to make a new directory. Exception city. x_x |
| 1760 |
< |
create_directory(destination); |
| 1761 |
< |
copy(*i,destination/i->filename()); |
| 1760 |
> |
create_directory(destination); |
| 1761 |
> |
copy(*i, destination/i->filename()); |
| 1762 |
|
} |
| 1763 |
|
} |
| 1764 |
|
} |