| 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()); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 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; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 991 | 
   | 
                         if (updateAE->InstallerVersion.compare(installerVersion) >= 1) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 998 | 
   | 
                         else | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 999 | 
   | 
                                 return UPDATE_SIMP_AVAIL; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1000 | 
   | 
                 } | 
 
 
 
 
 
 
 
 
 | 1001 | 
 + | 
                 else | 
 
 
 
 
 
 
 
 
 | 1002 | 
 + | 
                         return UPDATE_MNTH_REQD_ERR; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1003 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1004 | 
   | 
         try | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1005 | 
   | 
         { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1486 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1487 | 
   | 
         ProcessPackageUpdates(strPathToEUFNPackages, strPathToPackages); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1488 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 | 1489 | 
 < | 
         // Next, we get a list of which files and folders in the update's Globalize folder to move over; all files not starting with '.' will be moved... | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1490 | 
 < | 
         // ...and folders which do not exist in the current AE will be created there | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1491 | 
 < | 
         vector<string> foldersToMake, filesToMove; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1492 | 
 < | 
         string thePath; | 
 
 
 
 
 
 
 
 
 
 | 1489 | 
 > | 
         // Next, move over files in the update's Globalize folder; subfolders which do not exist in the current AE will be created by Boost's... | 
 
 
 
 
 
 | 1490 | 
 > | 
         // ...create_directories() function | 
 
 
 
 
 
 | 1491 | 
 > | 
         string strPath; | 
 
 
 
 
 
 | 1492 | 
 > | 
         path thePath; | 
 
 
 
 
 
 
 
 
 
 
 
 | 1493 | 
   | 
         for (recursive_directory_iterator dir_itr(strPathToEUFNPackages + strGlobalize), end_itr; dir_itr != end_itr; ++dir_itr) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1494 | 
   | 
         { | 
 
 
 
 
 
 
 
 
 
 
 
 | 1495 | 
 < | 
                 thePath = dir_itr->path().string(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1496 | 
 < | 
                 MakePathLocalToGlobalize(&thePath); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1495 | 
 > | 
                 strPath = dir_itr->path().string(); | 
 
 
 
 
 
 | 1496 | 
 > | 
                 MakePathLocalToGlobalize(&strPath); | 
 
 
 
 
 
 | 1497 | 
 > | 
                 thePath = (path)strPath; | 
 
 
 
 
 
 
 
 
 
 
 
 | 1498 | 
   | 
                 if (is_regular_file(dir_itr->status())) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1499 | 
   | 
                 { | 
 
 
 
 
 
 
 
 
 
 
 
 | 1500 | 
 < | 
                         if (dir_itr->filename().at(0) != '.') // skip over dot-files, which are invisible in Unix | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1501 | 
 < | 
                                 filesToMove.push_back(thePath); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1502 | 
 < | 
                 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1503 | 
 < | 
                 else if (is_directory(dir_itr->status())) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 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)) | 
 
 
 
 
 
 
 
 
 
 | 1500 | 
 > | 
                         if (thePath.filename().at(0) != '.') // skip over dot-files, which are invisible in Unix | 
 
 
 
 
 
 | 1501 | 
 > | 
                         { | 
 
 
 
 
 
 | 1502 | 
 > | 
                                 if (exists(strPathToPackages + strGlobalize + strPath)) | 
 
 
 
 
 
 | 1503 | 
 > | 
                                 { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1504 | 
   | 
 #ifdef WIN32 | 
 
 
 
 
 
 
 
 
 
 
 
 | 1505 | 
 < | 
                         remove((path)(strPathToPackages + strGlobalize + *iter)); | 
 
 
 
 
 
 
 
 
 
 | 1505 | 
 > | 
                                         remove((path)(strPathToPackages + strGlobalize + strPath)); | 
 
 
 
 
 
 
 
 
 
 
 
 | 1506 | 
   | 
 #else | 
 
 
 
 
 
 
 
 
 
 
 
 | 1507 | 
 < | 
                         rename((path)(strPathToPackages + strGlobalize + *iter), (path)(strTrashDir + *iter)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1507 | 
 > | 
                                         create_directories((path)(strTrashDir + thePath.parent_path().string())); | 
 
 
 
 
 
 | 1508 | 
 > | 
                                         rename((path)(strPathToPackages + strGlobalize + strPath), (path)(strTrashDir + strPath)); | 
 
 
 
 
 
 
 
 
 
 
 
 | 1509 | 
   | 
 #endif | 
 
 
 
 
 
 
 
 
 
 
 
 | 1510 | 
 < | 
                 rename((path)(strPathToEUFNPackages + strGlobalize + *iter), (path)(strPathToPackages + strGlobalize + *iter)); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1510 | 
 > | 
                                         rename((path)(strPathToEUFNPackages + strGlobalize + strPath), (path)(strPathToPackages + strGlobalize + strPath)); | 
 
 
 
 
 
 | 1511 | 
 > | 
                                 } | 
 
 
 
 
 
 | 1512 | 
 > | 
                                 else | 
 
 
 
 
 
 | 1513 | 
 > | 
                                 { | 
 
 
 
 
 
 | 1514 | 
 > | 
                                         int slashLoc = 0; | 
 
 
 
 
 
 | 1515 | 
 > | 
                                         slashLoc = strPath.find("/", 0); | 
 
 
 
 
 
 | 1516 | 
 > | 
                                         if (slashLoc != string::npos) // then path contains slashes, so we need to make sure its parents' paths exist before moving it | 
 
 
 
 
 
 | 1517 | 
 > | 
                                                 create_directories((path)(strPathToPackages + strGlobalize + thePath.parent_path().string())); | 
 
 
 
 
 
 | 1518 | 
 > | 
                                         rename((path)(strPathToEUFNPackages + strGlobalize + strPath), (path)(strPathToPackages + strGlobalize + strPath)); | 
 
 
 
 
 
 | 1519 | 
 > | 
                                 } | 
 
 
 
 
 
 | 1520 | 
 > | 
                         } | 
 
 
 
 
 
 | 1521 | 
 > | 
                 } | 
 
 
 
 
 
 
 
 
 
 
 
 | 1522 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1523 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1524 | 
   | 
         // Clean up after ourselves, trashing any packages or programs in the update package that are not newer than the current AE | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1554 | 
   | 
                 setStatusArea("Warning, handled exception: " + (string)ex.what()); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1555 | 
   | 
                 return false; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1556 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 | 1568 | 
 – | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1557 | 
   | 
 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1558 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1559 | 
   | 
 void ProcessPackageUpdates(string pathToUpdate, string strPathToPackages) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1738 | 
   | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1739 | 
   | 
         }  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1740 | 
   | 
         else if(from_ph.filename() != ".svn") | 
 
 
 
 
 
 
 
 
 
 
 
 | 1741 | 
 < | 
         {  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1742 | 
 < | 
                 path destination;  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1743 | 
 < | 
                 if(!exists(to_ph))  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1744 | 
 < | 
                 {  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1745 | 
 < | 
                         destination=to_ph;  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1746 | 
 < | 
                 }  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1747 | 
 < | 
                 else  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1748 | 
 < | 
                 {  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1749 | 
 < | 
                         destination=to_ph/from_ph.filename();  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1750 | 
 < | 
                 }  | 
 
 
 
 
 
 
 
 
 
 | 1741 | 
 > | 
         { | 
 
 
 
 
 
 | 1742 | 
 > | 
                 path destination; | 
 
 
 
 
 
 | 1743 | 
 > | 
                 if(!exists(to_ph)) | 
 
 
 
 
 
 | 1744 | 
 > | 
                 { | 
 
 
 
 
 
 | 1745 | 
 > | 
                         destination=to_ph; | 
 
 
 
 
 
 | 1746 | 
 > | 
                 } | 
 
 
 
 
 
 | 1747 | 
 > | 
                 else | 
 
 
 
 
 
 | 1748 | 
 > | 
                 { | 
 
 
 
 
 
 | 1749 | 
 > | 
                         destination=to_ph/from_ph.filename(); | 
 
 
 
 
 
 | 1750 | 
 > | 
                 } | 
 
 
 
 
 
 
 
 
 
 
 
 | 1751 | 
   | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 | 1752 | 
 < | 
                 for(directory_iterator i(from_ph); i!=directory_iterator(); ++i)  | 
 
 
 
 
 
 
 
 
 
 | 1752 | 
 > | 
                 for(directory_iterator i(from_ph); i!=directory_iterator(); ++i) | 
 
 
 
 
 
 
 
 
 
 
 
 | 1753 | 
   | 
                 {  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1754 | 
   | 
                         //the idiot who coded this in the first place (not me) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1755 | 
   | 
                         //forgot to make a new directory. Exception city. x_x | 
 
 
 
 
 
 
 
 
 
 
 
 | 1756 | 
 < | 
                         create_directory(destination);  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1757 | 
 < | 
                         copy(*i,destination/i->filename());  | 
 
 
 
 
 
 
 
 
 
 | 1756 | 
 > | 
                         create_directory(destination); | 
 
 
 
 
 
 | 1757 | 
 > | 
                         copy(*i, destination/i->filename()); | 
 
 
 
 
 
 
 
 
 
 
 
 | 1758 | 
   | 
                 }  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1759 | 
   | 
         }  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 1760 | 
   | 
 }  |