| 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) |
| 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 |
– |
*/ |
| 313 |
|
string prefsCommand = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '" |
| 314 |
|
+ fullAEpath + "'"; |
| 315 |
|
system(prefsCommand.c_str()); |
| 390 |
|
const string GlobalNeeded = "GlobalNeeded"; |
| 391 |
|
const string Category = "Category"; |
| 392 |
|
const string Creator = "Creator"; |
| 398 |
– |
package.modStringName = modName; |
| 393 |
|
while (!file.eof()) |
| 394 |
|
{ |
| 395 |
|
getline(file,line); |
| 420 |
|
iter++; |
| 421 |
|
package.modStringVersion = atof((*iter).c_str()); |
| 422 |
|
} |
| 423 |
< |
else if (!ModString.compare(*iter)) |
| 423 |
> |
else if (!ModVersion.compare(*iter)) |
| 424 |
|
{ |
| 425 |
|
iter++; iter++; |
| 426 |
|
package.modStringVersion = atof((*iter).c_str()); |
| 491 |
|
} |
| 492 |
|
} |
| 493 |
|
} |
| 494 |
< |
|
| 494 |
> |
package.modStringName = modName; |
| 495 |
|
return package; |
| 496 |
|
} |
| 497 |
|
|
| 657 |
|
vector<string> skippedfolders; |
| 658 |
|
|
| 659 |
|
ofstream BSLlog("BSL.log"); |
| 660 |
< |
if(exists("../GameDataFolder/BSLBackup/")) { |
| 667 |
< |
remove_all("../GameDataFolder/BSLBackup/"); |
| 668 |
< |
} |
| 669 |
< |
else { |
| 660 |
> |
if(!exists("../GameDataFolder/BSLBackup/")) { |
| 661 |
|
create_directory("../GameDataFolder/BSLBackup/"); |
| 662 |
+ |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 663 |
|
} |
| 664 |
< |
copy("../GameDataFolder/IGMD/", "../GameDataFolder/BSLBackup/"); |
| 664 |
> |
|
| 665 |
|
for ( directory_iterator dir_itr( "../GameDataFolder/IGMD/" ), end_itr; |
| 666 |
|
dir_itr != end_itr; |
| 667 |
|
++dir_itr ) { |
| 754 |
|
} |
| 755 |
|
} |
| 756 |
|
if (!skip_folder && !exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/ignore.txt")) { |
| 757 |
< |
remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); |
| 757 |
> |
if(!pkg.hasAddon) remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); |
| 758 |
|
Sleep(100); |
| 759 |
|
create_directory( "../GameDataFolder/IGMD/" + dir_itr->path().filename()); |
| 760 |
|
BSLlog << "Copied " << dir_itr->path().string() << " in " << pkg.modStringName << "!\n"; |
| 762 |
|
bsl_itr != end_itr; |
| 763 |
|
bsl_itr++ ) { |
| 764 |
|
if ( bsl_itr->path().extension() == ".bsl" ) { |
| 765 |
+ |
if(exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename())) |
| 766 |
+ |
remove("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 767 |
|
copy_file(bsl_itr->path(), "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); |
| 768 |
|
} |
| 769 |
|
} |
| 983 |
|
return UPDATE_LOG_READ_ERR; |
| 984 |
|
} |
| 985 |
|
|
| 986 |
< |
if (updateAE->AEVersion.compare(currentAE->AEVersion) >= 1) // is the release update newer than what's installed? |
| 986 |
> |
if (updateAE->AEVersion.compare(currentAE->AEVersion) > 0) // is the release update newer than what's installed? |
| 987 |
|
{ |
| 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 |
– |
} |
| 988 |
|
string strNewInstallerPath = "../updates/" + strEUFN + "/install/" + strInstallerName; |
| 989 |
|
string installerVersion = INSTALLER_VERSION; |
| 990 |
|
if (updateAE->InstallerVersion.compare(installerVersion) >= 1) |
| 997 |
|
else |
| 998 |
|
return UPDATE_SIMP_AVAIL; |
| 999 |
|
} |
| 1000 |
+ |
else |
| 1001 |
+ |
return UPDATE_MNTH_REQD_ERR; |
| 1002 |
|
} |
| 1003 |
|
try |
| 1004 |
|
{ |
| 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) |
| 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 |
|
} |