- attempt to make updates work for windows
This commit is contained in:
parent
efa7cb0346
commit
d13118ecf8
|
@ -370,4 +370,38 @@ void initSpecialStrings() {
|
||||||
getCompileDateTime();
|
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
|
}}//end namespace
|
||||||
|
|
|
@ -54,6 +54,8 @@ string formatString(string str);
|
||||||
string getGameReadWritePath(string lookupKey="");
|
string getGameReadWritePath(string lookupKey="");
|
||||||
string getGameCustomCoreDataPath(string originalBasePath, string uniqueFilePath);
|
string getGameCustomCoreDataPath(string originalBasePath, string uniqueFilePath);
|
||||||
|
|
||||||
|
bool upgradeFilesInTemp();
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -446,17 +446,19 @@ void MenuStateRoot::FTPClient_CallbackEvent(string itemName,
|
||||||
removeFile(tempFilePath + itemName);
|
removeFile(tempFilePath + itemName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move all files into binary folder
|
bool result = upgradeFilesInTemp();
|
||||||
vector<string> fileList = getFolderTreeContentsListRecursively(tempFilePath, "", false, NULL);
|
if(result == false) {
|
||||||
for(unsigned int index = 0; index < fileList.size(); ++index) {
|
string binaryName = Properties::getApplicationPath() + extractFileFromDirectoryPath(PlatformExceptionHandler::application_binary);
|
||||||
string fileName = fileList[index];
|
string binaryNameOld = Properties::getApplicationPath() + extractFileFromDirectoryPath(PlatformExceptionHandler::application_binary) + "__REMOVE";
|
||||||
string newFileName = Properties::getApplicationPath() + extractFileFromDirectoryPath(fileName);
|
bool resultRename = renameFile(binaryName,binaryNameOld);
|
||||||
bool result = renameFile(fileName,newFileName);
|
//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);
|
console.addLine("Successfully updated, please restart!",true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue