| 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" |
| 939 |
|
|
| 940 |
|
while (getline(*fileHandler, line)) |
| 941 |
|
{ |
| 942 |
+ |
StripNewlines(&line); |
| 943 |
|
tokenize(line, tokens); |
| 944 |
|
iter = tokens.begin(); |
| 945 |
|
|
| 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 |
| 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 |
|
|
| 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]; |
| 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); |
| 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 |
|
|
| 1288 |
|
if (exists(strPathToEUFNInstall + strWinGUI)) |
| 1289 |
|
{ |
| 1290 |
|
if (exists((path)strWinGUI)) |
| 1291 |
< |
rename((path)strWinGUI, (path)strcat(strTrashDir, strWinGUI)); |
| 1291 |
> |
rename((path)strWinGUI, (path)(strTrashDir + strWinGUI)); |
| 1292 |
|
if (exists(strWinGUILang)) |
| 1293 |
< |
rename((path)strWinGUILang, (path)strcat(strTrashDir, strWinGUILang)); |
| 1293 |
> |
rename((path)strWinGUILang, (path)(strTrashDir + strWinGUILang)); |
| 1294 |
|
rename((path)(strPathToEUFNInstall + strWinGUI), (path)strWinGUI); |
| 1295 |
|
rename((path)(strPathToEUFNInstall + strWinGUILang), (path)strWinGUILang); |
| 1296 |
|
} |
| 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 |
|
|
| 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 |
|
} |
| 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" ); |
| 1607 |
|
readme = ""; |
| 1608 |
|
globalNeeded = true; |
| 1609 |
|
} |
| 1610 |
< |
|
| 1610 |
> |
#ifndef WIN32 |
| 1611 |
|
void Sleep(int ms) |
| 1612 |
|
{ |
| 1613 |
|
sleep(ms / 1000); |
| 1614 |
|
} |
| 1615 |
< |
|
| 1615 |
> |
#endif |
| 1616 |
|
#ifdef WIN32 |
| 1617 |
|
|
| 1618 |
|
void RedirectIOToConsole() |