- attempt to make updates work for windows

This commit is contained in:
SoftCoder 2014-12-30 15:05:24 -08:00
parent efa7cb0346
commit d13118ecf8
3 changed files with 46 additions and 8 deletions

View File

@ -370,4 +370,38 @@ void initSpecialStrings() {
getCompileDateTime();
}
bool upgradeFilesInTemp() {
// Get path to temp files
string tempFilePath = "temp/";
if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") {
tempFilePath = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + tempFilePath;
}
else {
Config &config = Config::getInstance();
string userData = config.getString("UserData_Root","");
if(userData != "") {
endPathWithSlash(userData);
}
tempFilePath = userData + tempFilePath;
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Temp files path [%s]\n",tempFilePath.c_str());
// Move all files into binary folder
bool anyFailures = false;
vector<string> fileList = getFolderTreeContentsListRecursively(tempFilePath, "", false, NULL);
for(unsigned int index = 0; index < fileList.size(); ++index) {
string fileName = fileList[index];
string newFileName = Properties::getApplicationPath() + extractFileFromDirectoryPath(fileName);
bool result = renameFile(fileName,newFileName);
if(result == false) {
anyFailures = true;
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Rename: [%s] to [%s] result = %d\n",fileName.c_str(),newFileName.c_str(),result);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Successfully updated!\n");
return (fileList.size() > 0 && anyFailures == false);
}
}}//end namespace

View File

@ -54,6 +54,8 @@ string formatString(string str);
string getGameReadWritePath(string lookupKey="");
string getGameCustomCoreDataPath(string originalBasePath, string uniqueFilePath);
bool upgradeFilesInTemp();
}}//end namespace
#endif

View File

@ -446,17 +446,19 @@ void MenuStateRoot::FTPClient_CallbackEvent(string itemName,
removeFile(tempFilePath + itemName);
}
// Move all files into binary folder
vector<string> fileList = getFolderTreeContentsListRecursively(tempFilePath, "", false, NULL);
for(unsigned int index = 0; index < fileList.size(); ++index) {
string fileName = fileList[index];
string newFileName = Properties::getApplicationPath() + extractFileFromDirectoryPath(fileName);
bool result = renameFile(fileName,newFileName);
bool result = upgradeFilesInTemp();
if(result == false) {
string binaryName = Properties::getApplicationPath() + extractFileFromDirectoryPath(PlatformExceptionHandler::application_binary);
string binaryNameOld = Properties::getApplicationPath() + extractFileFromDirectoryPath(PlatformExceptionHandler::application_binary) + "__REMOVE";
bool resultRename = renameFile(binaryName,binaryNameOld);
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Rename: [%s] to [%s] result = %d\n",binaryName.c_str(),binaryNameOld.c_str(),resultRename);
printf("#1 Rename: [%s] to [%s] result = %d\n",binaryName.c_str(),binaryNameOld.c_str(),resultRename);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Rename: [%s] to [%s] result = %d\n",fileName.c_str(),newFileName.c_str(),result);
result = upgradeFilesInTemp();
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Rename: [%s] to [%s] result = %d\n",binaryName.c_str(),binaryNameOld.c_str(),resultRename);
printf("#2 Rename: [%s] to [%s] result = %d\n",binaryName.c_str(),binaryNameOld.c_str(),resultRename);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Successfully updated!\n");
console.addLine("Successfully updated, please restart!",true);
}
else {