ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/AE/Installer/trunk/source/installer.cpp
(Generate patch)

Comparing AE/Installer/trunk/source/installer.cpp (file contents):
Revision 487 by iritscen, Wed Dec 30 01:51:38 2009 UTC vs.
Revision 496 by gumby, Mon Feb 22 00:00:55 2010 UTC

# Line 9 | Line 9
9   // TODO: Load credits from text resource file
10   // TODO: Clear mod info fields when mod is de-selected
11  
12 < #define DEBUG
13 <
12 > //#define DEBUG
13 > #ifdef WIN32
14 > //#include <windows.h>
15 > #define popen _popen
16 > #endif
17   #include "boost/date_time/gregorian/gregorian.hpp"
18   #include "boost/date_time/date_parsing.hpp"
19   #include "boost/date_time/posix_time/posix_time.hpp"
# Line 1139 | Line 1142 | bool ProcessInstallerUpdate(Install_info
1142          string popenCommand = "../updates/" + strEUFN + "/install/";
1143   #ifdef WIN32
1144          // TODO: Fill in Windows equivalent of code below :-3
1145 +        popenCommand = "replace_installer.bat";
1146   #else
1147          // We can't just use '~' to mean "the home directory" because we need to check the path in C...
1148          // ...so we actually get the current user's shortname and manually construct the path to home
# Line 1160 | Line 1164 | bool ProcessInstallerUpdate(Install_info
1164   #endif
1165          file.close();
1166          file.clear();
1167 + #ifdef WIN32
1168 +        system(popenCommand.c_str());
1169 + #else
1170          popen(popenCommand.c_str(), "r");
1171 <        
1171 > #endif
1172          return true; // returning 'true' tells the Installer to quit itself ASAP so it can be replaced by the process that is now running
1173   }
1174  
# Line 1192 | Line 1199 | bool ProcessAEUpdate(Install_info_cfg *c
1199          
1200          // TODO: Fill in Windows equivalent of code below
1201   #ifdef WIN32
1202 <        string strTrashDir = "%RECYCLE%";
1202 >        string strTrashDir = "Trash\\";
1203   #else
1204          FILE *fUserName = NULL;
1205          char chrUserName[32];
# Line 1237 | Line 1244 | bool ProcessAEUpdate(Install_info_cfg *c
1244                                  needNewTrashDir = true;
1245                  }
1246          }
1247 <        
1247 > #ifndef WIN32
1248          if (!*installerJustUpdated || needNewTrashDir) // prepare a new directory for deleted files to go to
1249          {
1250                  tm tmStartTime = to_tm(startTime);
# Line 1245 | Line 1252 | bool ProcessAEUpdate(Install_info_cfg *c
1252                                            boost::lexical_cast<string>(tmStartTime.tm_min) + "-" + boost::lexical_cast<string>(tmStartTime.tm_sec) + "/";
1253                  create_directory(strTrashDir);
1254          }
1255 + #endif
1256          file.close();
1257          file.clear();
1258  
# Line 1279 | Line 1287 | bool ProcessAEUpdate(Install_info_cfg *c
1287                  if (exists(strPathToEUFNInstall + strWinGUI))
1288                  {
1289                          if (exists((path)strWinGUI))
1290 <                                rename((path)strWinGUI, (path)strcat(strTrashDir, strWinGUI));
1290 >                                rename((path)strWinGUI, (path)(strTrashDir + strWinGUI));
1291                          if (exists(strWinGUILang))
1292 <                                rename((path)strWinGUILang, (path)strcat(strTrashDir, strWinGUILang));
1292 >                                rename((path)strWinGUILang, (path)(strTrashDir + strWinGUILang));
1293                          rename((path)(strPathToEUFNInstall + strWinGUI), (path)strWinGUI);
1294                          rename((path)(strPathToEUFNInstall + strWinGUILang), (path)strWinGUILang);
1295                  }
# Line 1320 | Line 1328 | bool ProcessAEUpdate(Install_info_cfg *c
1328                                  curPos = thePath.find("/", lastPos);
1329                                  aParentPath = aParentPath + "/";
1330                          }
1331 + #ifndef WIN32
1332                          rename((path)("../" + thePath), (path)(strTrashDir + thePath));
1333 + #else
1334 +                        remove((path)("../" + thePath));
1335 + #endif
1336                  }
1337          }
1338          
# Line 1343 | Line 1355 | bool ProcessAEUpdate(Install_info_cfg *c
1355                                  matchFound = true;
1356                                  if (iter1->modStringVersion > iter2->modStringVersion)
1357                                  {
1358 + #ifndef WIN32
1359                                          rename((path)(strPathToPackages + iter2->modStringName), (path)(strTrashDir + iter2->modStringName));
1360 + #else
1361 +                                        remove((path)(strPathToPackages + iter2->modStringName));
1362 + #endif
1363                                          rename((path)(strPathToEUFNPackages + iter1->modStringName), (path)(strPathToPackages + iter1->modStringName));
1364                                  }
1365                          }
# Line 1579 | Line 1595 | ModPackage::ModPackage()
1595          readme = "";
1596          globalNeeded = true;
1597   }
1598 <
1598 > #ifndef WIN32
1599   void Sleep(int ms)
1600   {
1601          sleep(ms / 1000);
1602   }
1603 <
1603 > #endif
1604   #ifdef WIN32
1605  
1606   void RedirectIOToConsole()

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)