| 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; |
| 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 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()); |
| 316 |
– |
strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters |
| 317 |
– |
*/ |
| 312 |
|
string prefsCommand = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '" |
| 313 |
|
+ fullAEpath + "'"; |
| 314 |
|
system(prefsCommand.c_str()); |
| 347 |
|
if (!file.fail()) |
| 348 |
|
{ |
| 349 |
|
package = fileToModPackage(file, dir_itr->path().filename()); |
| 350 |
< |
if (package.installerVersion.compare(INSTALLER_VERSION) < 1) // if mod requires newer version of the Installer, we won't add it to the list |
| 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 |
| 374 |
|
ModPackage fileToModPackage(fstream &file, string modName) |
| 375 |
|
{ |
| 376 |
|
ModPackage package; |
| 382 |
– |
string line; |
| 377 |
|
const string AEInstallVersion = "AEInstallVersion"; // used for comparing to the current token... |
| 378 |
|
const string NameOfMod = "NameOfMod"; |
| 379 |
|
const string ARROW = "->"; |
| 389 |
|
const string GlobalNeeded = "GlobalNeeded"; |
| 390 |
|
const string Category = "Category"; |
| 391 |
|
const string Creator = "Creator"; |
| 398 |
– |
package.modStringName = modName; |
| 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++; |
| 422 |
|
iter++; |
| 423 |
|
package.modStringVersion = atof((*iter).c_str()); |
| 424 |
|
} |
| 425 |
< |
else if (!ModString.compare(*iter)) |
| 425 |
> |
else if (!ModVersion.compare(*iter)) |
| 426 |
|
{ |
| 427 |
|
iter++; iter++; |
| 428 |
|
package.modStringVersion = atof((*iter).c_str()); |
| 493 |
|
} |
| 494 |
|
} |
| 495 |
|
} |
| 496 |
< |
|
| 496 |
> |
package.modStringName = modName; |
| 497 |
|
return package; |
| 498 |
|
} |
| 499 |
|
|
| 659 |
|
vector<string> skippedfolders; |
| 660 |
|
|
| 661 |
|
ofstream BSLlog("BSL.log"); |
| 662 |
< |
if(exists("../GameDataFolder/BSLBackup/")) { |
| 667 |
< |
remove_all("../GameDataFolder/BSLBackup/"); |
| 668 |
< |
} |
| 669 |
< |
else { |
| 662 |
> |
if(!exists("../GameDataFolder/BSLBackup/")) { |
| 663 |
|
create_directory("../GameDataFolder/BSLBackup/"); |
| 664 |
+ |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 665 |
|
} |
| 666 |
< |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 666 |
> |
|
| 667 |
|
for ( directory_iterator dir_itr( "../GameDataFolder/IGMD/" ), end_itr; |
| 668 |
|
dir_itr != end_itr; |
| 669 |
|
++dir_itr ) { |
| 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 |
|
} |
| 943 |
|
else if (readingInstallerVersion && tokens.capacity() >= 3) |
| 944 |
|
{ |
| 945 |
|
readingInstallerVersion = false; |
| 946 |
< |
string installerVersion = INSTALLER_VERSION; |
| 951 |
< |
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(); |
| 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 |
|
{ |
| 994 |
– |
if (!strEUFN.compare("Edition-patch")) // if update is a patch... |
| 995 |
– |
{ |
| 996 |
– |
if (currentAE->AEVersion.compare(updateAE->AEVersion.substr(0, updateAE->AEVersion.length() - 1))) // ...is it for a different month? |
| 997 |
– |
return UPDATE_MNTH_REQD_ERR; |
| 998 |
– |
} |
| 989 |
|
string strNewInstallerPath = "../updates/" + strEUFN + "/install/" + strInstallerName; |
| 990 |
< |
string installerVersion = INSTALLER_VERSION; |
| 1001 |
< |
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 |
| 1004 |
|
{ |
| 1029 |
|
file.close(); |
| 1030 |
|
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1031 |
|
{ |
| 1032 |
< |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
| 1032 |
> |
if (updatePackage.installerVersion.compare(gInstallerVersion) < 1) |
| 1033 |
|
return UPDATE_PKG_AVAIL; |
| 1034 |
|
} |
| 1035 |
|
} |
| 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 |
|
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())) |
| 1511 |
< |
{ |
| 1512 |
< |
if (!exists(strPathToPackages + strGlobalize + thePath)) |
| 1513 |
< |
foldersToMake.push_back(thePath); |
| 1514 |
< |
} |
| 1515 |
< |
} |
| 1516 |
< |
// Sort the foldersToMake strings by length, which is a fast solution to the problem of "How do we make sure we create folder 'parent/'... |
| 1517 |
< |
// ...before folder 'parent/child/'"? |
| 1518 |
< |
sort(foldersToMake.begin(), foldersToMake.end(), SortBySize); // SortBySize is a custom comparison function found later in this source file |
| 1519 |
< |
// First make the folders that don't exist in the current AE, so all the files have a place to go |
| 1520 |
< |
for (vector<string>::iterator iter = foldersToMake.begin(); iter != foldersToMake.end(); iter++) |
| 1521 |
< |
{ |
| 1522 |
< |
create_directory(strPathToPackages + strGlobalize + *iter); |
| 1523 |
< |
} |
| 1524 |
< |
for (vector<string>::iterator iter = filesToMove.begin(); iter != filesToMove.end(); iter++) |
| 1525 |
< |
{ |
| 1526 |
< |
if (exists(strPathToPackages + strGlobalize + *iter)) |
| 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 + *iter)); |
| 1504 |
> |
remove((path)(strPathToPackages + strGlobalize + strPath)); |
| 1505 |
|
#else |
| 1506 |
< |
rename((path)(strPathToPackages + strGlobalize + *iter), (path)(strTrashDir + *iter)); |
| 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 + *iter), (path)(strPathToPackages + strGlobalize + *iter)); |
| 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 |
|
} |
| 1522 |
|
|
| 1523 |
|
// Clean up after ourselves, trashing any packages or programs in the update package that are not newer than the current AE |
| 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 |
|
} |
| 1568 |
– |
|
| 1561 |
|
} |
| 1562 |
|
|
| 1563 |
|
void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages) |
| 1616 |
|
file.close(); |
| 1617 |
|
if (updatePackage.modStringVersion > installedPackage.modStringVersion) |
| 1618 |
|
{ |
| 1619 |
< |
if (updatePackage.installerVersion <= INSTALLER_VERSION) |
| 1619 |
> |
if (updatePackage.installerVersion.compare(gInstallerVersion) < 1) |
| 1620 |
|
{ |
| 1621 |
|
if(exists(strPathToPackages + "/" + updatePackage.modStringName)) { |
| 1622 |
|
#ifdef WIN32 |
| 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 |
|
} |