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 489 by gumby, Sun Jan 24 23:58:16 2010 UTC vs.
Revision 499 by iritscen, Wed Mar 3 02:09:02 2010 UTC

# Line 939 | Line 939 | bool ReadInstallInfoCfg(fstream *fileHan
939          
940          while (getline(*fileHandler, line))
941          {
942 +                StripNewlines(&line);
943                  tokenize(line, tokens);
944                  iter = tokens.begin();
945                  
# Line 1142 | Line 1143 | bool ProcessInstallerUpdate(Install_info
1143          string popenCommand = "../updates/" + strEUFN + "/install/";
1144   #ifdef WIN32
1145          // TODO: Fill in Windows equivalent of code below :-3
1146 +        popenCommand = "replace_installer.bat";
1147   #else
1148          // We can't just use '~' to mean "the home directory" because we need to check the path in C...
1149          // ...so we actually get the current user's shortname and manually construct the path to home
# Line 1163 | Line 1165 | bool ProcessInstallerUpdate(Install_info
1165   #endif
1166          file.close();
1167          file.clear();
1168 + #ifdef WIN32
1169 +        system(popenCommand.c_str());
1170 + #else
1171          popen(popenCommand.c_str(), "r");
1172 <        
1172 > #endif
1173          return true; // returning 'true' tells the Installer to quit itself ASAP so it can be replaced by the process that is now running
1174   }
1175  
# Line 1195 | Line 1200 | bool ProcessAEUpdate(Install_info_cfg *c
1200          
1201          // TODO: Fill in Windows equivalent of code below
1202   #ifdef WIN32
1203 <        string strTrashDir = "%RECYCLE%";
1203 >        string strTrashDir = "Trash\\";
1204   #else
1205          FILE *fUserName = NULL;
1206          char chrUserName[32];
# Line 1240 | Line 1245 | bool ProcessAEUpdate(Install_info_cfg *c
1245                                  needNewTrashDir = true;
1246                  }
1247          }
1248 <        
1248 > #ifndef WIN32
1249          if (!*installerJustUpdated || needNewTrashDir) // prepare a new directory for deleted files to go to
1250          {
1251                  tm tmStartTime = to_tm(startTime);
# Line 1248 | Line 1253 | bool ProcessAEUpdate(Install_info_cfg *c
1253                                            boost::lexical_cast<string>(tmStartTime.tm_min) + "-" + boost::lexical_cast<string>(tmStartTime.tm_sec) + "/";
1254                  create_directory(strTrashDir);
1255          }
1256 + #endif
1257          file.close();
1258          file.clear();
1259  
# Line 1323 | Line 1329 | bool ProcessAEUpdate(Install_info_cfg *c
1329                                  curPos = thePath.find("/", lastPos);
1330                                  aParentPath = aParentPath + "/";
1331                          }
1332 + #ifndef WIN32
1333                          rename((path)("../" + thePath), (path)(strTrashDir + thePath));
1334 + #else
1335 +                        remove((path)("../" + thePath));
1336 + #endif
1337                  }
1338          }
1339          
# Line 1346 | Line 1356 | bool ProcessAEUpdate(Install_info_cfg *c
1356                                  matchFound = true;
1357                                  if (iter1->modStringVersion > iter2->modStringVersion)
1358                                  {
1359 + #ifndef WIN32
1360                                          rename((path)(strPathToPackages + iter2->modStringName), (path)(strTrashDir + iter2->modStringName));
1361 + #else
1362 +                                        remove((path)(strPathToPackages + iter2->modStringName));
1363 + #endif
1364                                          rename((path)(strPathToEUFNPackages + iter1->modStringName), (path)(strPathToPackages + iter1->modStringName));
1365                                  }
1366                          }
# Line 1457 | Line 1471 | void tokenize(const string& str, vector<
1471          }
1472   }
1473  
1474 + /* StripNewlines() gets rids of any linebreaks that come from text returned by getline(); \
1475 + |  getline() should be stripping those out, but Windows CR/LF files seem to be sneaking   |
1476 + \  some extra return characters into strings in the ReadInstallInfoCfg() function.               */
1477 + void StripNewlines(string *theLine)
1478 + {
1479 +        int deleteFromHere = 0;
1480 +        deleteFromHere = theLine->find("\r");
1481 +        if (deleteFromHere > 0)
1482 +                theLine->erase(deleteFromHere, theLine->size());
1483 + }
1484 +
1485   void clearOldDats(void) {
1486          directory_iterator end_iter_gdf;
1487          for ( directory_iterator dir_itr_gdf( "../GameDataFolder" );

Diff Legend

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