| 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 |
|
{ |
| 232 |
|
|
| 233 |
|
|
| 234 |
|
if ( strcmp(levels[i].c_str(), "0") ){ |
| 235 |
< |
system((strOniSplit + " -move:overwrite ../GameDataFolder/level" + levels[i] + "_Final ../GameDataFolder/level" + levels[i] + "_Final/AKEV/AKEV*.oni").c_str()); |
| 235 |
> |
system((strOniSplit + " -move:overwrite ../GameDataFolder/level" + levels[i] + "_Final ../GameDataFolder/level" + levels[i] + |
| 236 |
> |
"_Final/AKEV/AKEV*.oni").c_str()); |
| 237 |
|
remove( "../GameDataFolder/level" + levels[i] + "_Final/AKEV" ); |
| 238 |
|
} |
| 239 |
|
|
| 247 |
|
for (int i = 0; i < 15; i++) |
| 248 |
|
{ |
| 249 |
|
logfile << "\tReimporting level" << levels[i] << "_Final.oni\n"; |
| 250 |
< |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + levels[i]+"_Final.oni"); |
| 250 |
> |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + |
| 251 |
> |
levels[i] + "_Final.oni"); |
| 252 |
|
logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" |
| 253 |
|
+ levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str() << '\n'; |
| 254 |
|
string sys_str = (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" |
| 309 |
|
/* 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). |
| 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 the folder that *contains* the GDF) |
| 312 |
> |
string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for Edition/ (Oni wants folder that *contains* the GDF) |
| 313 |
|
//bad Iritscen, bad! fixed buffers can cause crashes. |
| 314 |
|
/*char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '"; |
| 315 |
|
strcat(prefsCommand, fullAEpath.c_str()); |
| 377 |
|
} |
| 378 |
|
|
| 379 |
|
ModPackage fileToModPackage(fstream &file, string modName) |
| 380 |
< |
{ |
| 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 |
< |
|
| 380 |
> |
{ |
| 381 |
|
ModPackage package; |
| 382 |
|
string line; |
| 383 |
|
const string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... |
| 569 |
|
|
| 570 |
|
|
| 571 |
|
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
| 572 |
< |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); |
| 572 |
> |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
| 573 |
> |
dir_itr->path().filename() + " "); |
| 574 |
|
|
| 575 |
|
system(importCommand.c_str()); |
| 576 |
|
j++; |
| 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 ); |
| 619 |
< |
dir_itr != end_iter; |
| 620 |
< |
++dir_itr ) |
| 621 |
< |
{ |
| 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 " + dir_itr->path().filename() + " "); |
| 645 |
> |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + |
| 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); |
| 741 |
|
|
| 742 |
|
void copyBSL(string copypath, vector<string>& BSLfolders, ModPackage pkg) |
| 743 |
|
{ |
| 744 |
< |
ofstream BSLlog("BSL2.log", ios::app ); |
| 744 |
> |
ofstream BSLlog("BSL.log", ios::app ); |
| 745 |
|
|
| 746 |
|
try { |
| 747 |
|
for ( directory_iterator dir_itr( copypath ), end_itr; |
| 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 |
|
} |
| 852 |
|
| Installer to be replaced (when the new Installer | |
| 853 |
|
| launches, this function will be called again but will | |
| 854 |
|
| return UPDATE_SIMP_AVAIL or UPDATE_GLOB_AVAIL) | |
| 855 |
+ |
| UPDATE_PKG_AVAIL -- A newer version of individual package(s) is available | |
| 856 |
|
\* UPDATE_CONT_UPD -- Currently unused */ |
| 857 |
|
int GetUpdateStatus(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) |
| 858 |
|
{ |
| 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; |
| 970 |
|
} |
| 971 |
|
newUpdateLog << "Installer was updated to:\n"; |
| 972 |
|
newUpdateLog << newUpdateLine.c_str(); |
| 973 |
< |
*installerJustUpdated = true; // this value is indirectly returned to AEInstallerAp::OnInit() |
| 973 |
> |
*installerJustUpdated = true; // this value is indirectly returned to AEInstallerApp::OnInit() |
| 974 |
|
doneReadingFile = true; |
| 975 |
|
newUpdateLog.close(); |
| 976 |
|
newUpdateLog.clear(); |
| 1009 |
|
return UPDATE_SIMP_AVAIL; |
| 1010 |
|
} |
| 1011 |
|
} |
| 1012 |
< |
try { |
| 973 |
< |
directory_iterator end; |
| 974 |
< |
if(exists("../updates")){ |
| 975 |
< |
for ( directory_iterator install_iter( "../updates" ); |
| 976 |
< |
install_iter != end; |
| 977 |
< |
++install_iter ) |
| 1012 |
> |
try |
| 1013 |
|
{ |
| 1014 |
< |
|
| 1015 |
< |
ModPackage installedPackage, updatePackage; |
| 1016 |
< |
if ( is_directory( install_iter->path() ) && exists( install_iter->path().string() + "/Mod_Info.cfg" ) ) { |
| 1017 |
< |
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 |
| 1014 |
> |
directory_iterator end; |
| 1015 |
> |
if (exists("../updates")) |
| 1016 |
> |
{ |
| 1017 |
> |
for (directory_iterator install_iter("../updates"); install_iter != end; ++install_iter) |
| 1018 |
|
{ |
| 1019 |
< |
file.close(); |
| 1020 |
< |
return UPDATE_THIRD_PARTY; |
| 1021 |
< |
} |
| 1022 |
< |
file.close(); |
| 1023 |
< |
if(updatePackage.modStringVersion > installedPackage.modStringVersion) { |
| 1024 |
< |
return UPDATE_THIRD_PARTY; |
| 1019 |
> |
ModPackage installedPackage, updatePackage; |
| 1020 |
> |
if (is_directory(install_iter->path()) && exists(install_iter->path().string() + "/Mod_Info.cfg")) |
| 1021 |
> |
{ |
| 1022 |
> |
fstream file; |
| 1023 |
> |
file.open((install_iter->path().string() + "/Mod_Info.cfg").c_str()); |
| 1024 |
> |
if (!file.fail()) |
| 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")) |
| 1032 |
> |
{ |
| 1033 |
> |
file.close(); |
| 1034 |
> |
file.clear(); |
| 1035 |
> |
file.open(("packages/" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); |
| 1036 |
> |
if (!file.fail()) |
| 1037 |
> |
installedPackage = fileToModPackage(file, install_iter->path().filename()); |
| 1038 |
> |
file.close(); |
| 1039 |
> |
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1040 |
> |
{ |
| 1041 |
> |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
| 1042 |
> |
return UPDATE_PKG_AVAIL; |
| 1043 |
> |
} |
| 1044 |
> |
} |
| 1045 |
> |
else |
| 1046 |
> |
{ |
| 1047 |
> |
file.close(); |
| 1048 |
> |
return UPDATE_PKG_AVAIL; |
| 1049 |
> |
} |
| 1050 |
> |
} |
| 1051 |
|
} |
| 1009 |
– |
|
| 1052 |
|
} |
| 1011 |
– |
} |
| 1012 |
– |
|
| 1013 |
– |
} |
| 1053 |
|
} |
| 1054 |
|
catch (exception & ex) { |
| 1055 |
|
// setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 1056 |
|
} |
| 1018 |
– |
|
| 1057 |
|
|
| 1058 |
|
return UPDATE_NO_UPD_AVAIL; |
| 1059 |
|
} |
| 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 = "->"; |
| 1280 |
|
|
| 1281 |
|
string popenCommand = "../updates/" + strEUFN + "/install/"; |
| 1282 |
|
#ifdef WIN32 |
| 1245 |
– |
// TODO: Fill in Windows equivalent of code below :-3 |
| 1283 |
|
popenCommand = "replace_installer.bat"; |
| 1284 |
|
#else |
| 1285 |
|
// We can't just use '~' to mean "the home directory" because we need to check the path in C... |
| 1309 |
|
#endif |
| 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 |
|
} |
| 1275 |
– |
//strPathToEUFNPackages |
| 1276 |
– |
|
| 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 |
– |
else |
| 1300 |
– |
{ |
| 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 |
– |
else |
| 1318 |
– |
{ |
| 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 |
– |
|
| 1312 |
|
|
| 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"; |
| 1367 |
– |
#endif |
| 1335 |
|
bool needNewTrashDir = false; |
| 1336 |
+ |
#endif |
| 1337 |
+ |
|
| 1338 |
|
bool readingVerAndDate = false; |
| 1339 |
|
|
| 1371 |
– |
// TODO: Fill in Windows equivalent of code below |
| 1340 |
|
#ifdef WIN32 |
| 1341 |
< |
string strTrashDir = "Trash\\"; |
| 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 + "/"; |
| 1492 |
|
} |
| 1493 |
|
} |
| 1494 |
|
|
| 1495 |
< |
CrawlPackages( strPathToEUFNPackages, strPathToPackages); |
| 1495 |
> |
ProcessPackageUpdates(strPathToEUFNPackages, strPathToPackages); |
| 1496 |
|
|
| 1497 |
|
// 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... |
| 1498 |
|
// ...and folders which do not exist in the current AE will be created there |
| 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) |
| 1572 |
+ |
{ |
| 1573 |
+ |
ptime startTime(second_clock::local_time()); |
| 1574 |
+ |
#ifdef WIN32 |
| 1575 |
+ |
string strTrashDir = "Trash\\"; // string unused in Windows because files are simply deleted |
| 1576 |
+ |
#else |
| 1577 |
+ |
FILE *fUserName = NULL; |
| 1578 |
+ |
char chrUserName[32]; |
| 1579 |
+ |
fUserName = popen("whoami", "r"); |
| 1580 |
+ |
fgets(chrUserName, sizeof(chrUserName), fUserName); |
| 1581 |
+ |
pclose(fUserName); |
| 1582 |
+ |
string strUserName = (string)chrUserName; // stringsblaaarrrgggghhhh |
| 1583 |
+ |
int endOfName = strUserName.find("\n", 0); |
| 1584 |
+ |
string strTrashDir = "/Users/" + strUserName.substr(0, endOfName) + "/.Trash/"; |
| 1585 |
+ |
bool needNewTrashDir = true; |
| 1586 |
+ |
tm tmStartTime = to_tm(startTime); |
| 1587 |
+ |
#endif |
| 1588 |
+ |
|
| 1589 |
+ |
try |
| 1590 |
+ |
{ |
| 1591 |
+ |
directory_iterator end; |
| 1592 |
+ |
for (directory_iterator update_iter(pathToUpdate); update_iter != end; ++update_iter) |
| 1593 |
+ |
{ |
| 1594 |
+ |
ModPackage installedPackage, updatePackage; |
| 1595 |
+ |
string updtPath = update_iter->path().string(); |
| 1596 |
+ |
string updtFolder = update_iter->path().filename(); |
| 1597 |
+ |
string updtModInfo = updtPath + "/Mod_Info.cfg"; |
| 1598 |
+ |
string instModInfo = strPathToPackages + "/" + updtFolder + "/Mod_Info.cfg"; |
| 1599 |
+ |
if (!boost::iequals(updtFolder, "Edition") |
| 1600 |
+ |
&& !boost::iequals(updtFolder, "Edition-patch") |
| 1601 |
+ |
&& is_directory(update_iter->path()) |
| 1602 |
+ |
&& exists(updtModInfo)) |
| 1603 |
+ |
{ |
| 1604 |
+ |
fstream file; |
| 1605 |
+ |
file.open((updtModInfo).c_str()); |
| 1606 |
+ |
if (!file.fail()) |
| 1607 |
+ |
updatePackage = fileToModPackage(file, updtFolder); |
| 1608 |
+ |
else |
| 1609 |
+ |
{ |
| 1610 |
+ |
file.close(); |
| 1611 |
+ |
continue; |
| 1612 |
+ |
} |
| 1613 |
+ |
if (exists(instModInfo)) |
| 1614 |
+ |
{ |
| 1615 |
+ |
file.close(); |
| 1616 |
+ |
file.clear(); |
| 1617 |
+ |
file.open(instModInfo.c_str()); |
| 1618 |
+ |
if (!file.fail()) |
| 1619 |
+ |
{ |
| 1620 |
+ |
installedPackage = fileToModPackage(file, updtFolder); |
| 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 + "/" + 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; |
| 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 |
+ |
} |
| 1645 |
+ |
} |
| 1646 |
+ |
} |
| 1647 |
+ |
} |
| 1648 |
+ |
} |
| 1649 |
+ |
catch (exception & ex) |
| 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 \ |