- proper detection that user does not have 7z installed in their path
This commit is contained in:
parent
51ae014124
commit
42a6737960
|
@ -32,6 +32,7 @@ FastSpeedLoops=2
|
|||
FileArchiveExtension=.7z
|
||||
FileArchiveExtractCommand=7z
|
||||
FileArchiveExtractCommandParameters=x -o{outputpath} {archivename}
|
||||
FileArchiveExtractCommandSuccessResult=0
|
||||
Filter=Bilinear
|
||||
FilterMaxAnisotropy=1
|
||||
FirstTime=false
|
||||
|
|
|
@ -455,11 +455,12 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
string fileArchiveExtension = config.getString("FileArchiveExtension","");
|
||||
string fileArchiveExtractCommand = config.getString("FileArchiveExtractCommand","");
|
||||
string fileArchiveExtractCommandParameters = config.getString("FileArchiveExtractCommandParameters","");
|
||||
int32 fileArchiveExtractCommandSuccessResult = config.getInt("FileArchiveExtractCommandSuccessResult","0");
|
||||
|
||||
ftpClientThread = new FTPClientThread(portNumber,serverUrl,
|
||||
mapsPath,tilesetsPath,techtreesPath,scenariosPath,
|
||||
this,fileArchiveExtension,fileArchiveExtractCommand,
|
||||
fileArchiveExtractCommandParameters);
|
||||
fileArchiveExtractCommandParameters,fileArchiveExtractCommandSuccessResult);
|
||||
ftpClientThread->start();
|
||||
}
|
||||
|
||||
|
|
|
@ -245,13 +245,15 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
|
|||
string fileArchiveExtension = config.getString("FileArchiveExtension","");
|
||||
string fileArchiveExtractCommand = config.getString("FileArchiveExtractCommand","");
|
||||
string fileArchiveExtractCommandParameters = config.getString("FileArchiveExtractCommandParameters","");
|
||||
int32 fileArchiveExtractCommandSuccessResult = config.getInt("FileArchiveExtractCommandSuccessResult","0");
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
ftpClientThread = new FTPClientThread(-1,"",
|
||||
mapsPath,tilesetsPath,techtreesPath,scenariosPath,
|
||||
this,fileArchiveExtension,fileArchiveExtractCommand,
|
||||
fileArchiveExtractCommandParameters);
|
||||
fileArchiveExtractCommandParameters,
|
||||
fileArchiveExtractCommandSuccessResult);
|
||||
ftpClientThread->start();
|
||||
|
||||
|
||||
|
@ -274,7 +276,8 @@ void MenuStateMods::simpleTask(BaseThread *callingThread) {
|
|||
Lang &lang= Lang::getInstance();
|
||||
Config &config = Config::getInstance();
|
||||
string fileArchiveExtractCommand = config.getString("FileArchiveExtractCommand","");
|
||||
bool findArchive = executeShellCommand(fileArchiveExtractCommand);
|
||||
int expectedResult = config.getInt("FileArchiveExtractCommandSuccessResult","0");
|
||||
bool findArchive = executeShellCommand(fileArchiveExtractCommand,expectedResult);
|
||||
if(findArchive == false) {
|
||||
mainMessageBoxState = ftpmsg_None;
|
||||
mainMessageBox.init(lang.get("Ok"));
|
||||
|
|
|
@ -39,6 +39,7 @@ using Shared::Util::Checksum;
|
|||
|
||||
namespace Shared { namespace PlatformCommon {
|
||||
|
||||
static const int IGNORE_CMD_RESULT_VALUE = -999999;
|
||||
// =====================================================
|
||||
// class PerformanceTimer
|
||||
// =====================================================
|
||||
|
@ -191,7 +192,7 @@ inline string trim (const string & s, const string & t = SPACES) {
|
|||
|
||||
string getFullFileArchiveExtractCommand(string fileArchiveExtractCommand,
|
||||
string fileArchiveExtractCommandParameters, string outputpath, string archivename);
|
||||
bool executeShellCommand(string cmd);
|
||||
bool executeShellCommand(string cmd,int expectedResult=IGNORE_CMD_RESULT_VALUE);
|
||||
|
||||
class ValueCheckerVault {
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ protected:
|
|||
string fileArchiveExtension;
|
||||
string fileArchiveExtractCommand;
|
||||
string fileArchiveExtractCommandParameters;
|
||||
int fileArchiveExtractCommandSuccessResult;
|
||||
|
||||
pair<FTP_Client_ResultType,string> getFileFromServer(FTP_Client_CallbackType downloadType,
|
||||
pair<string,string> fileNameTitle,
|
||||
|
@ -120,7 +121,8 @@ public:
|
|||
FTPClientCallbackInterface *pCBObject,
|
||||
string fileArchiveExtension,
|
||||
string fileArchiveExtractCommand,
|
||||
string fileArchiveExtractCommandParameters);
|
||||
string fileArchiveExtractCommandParameters,
|
||||
int fileArchiveExtractCommandSuccessResult);
|
||||
virtual void execute();
|
||||
virtual void signalQuit();
|
||||
virtual bool shutdownAndWait();
|
||||
|
|
|
@ -1475,7 +1475,7 @@ string getFullFileArchiveExtractCommand(string fileArchiveExtractCommand,
|
|||
return result;
|
||||
}
|
||||
|
||||
bool executeShellCommand(string cmd) {
|
||||
bool executeShellCommand(string cmd, int expectedResult) {
|
||||
bool result = false;
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nAbout to run [%s]", cmd.c_str());
|
||||
|
||||
|
@ -1501,8 +1501,8 @@ bool executeShellCommand(string cmd) {
|
|||
#endif
|
||||
|
||||
/* Close pipe and print return value. */
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nProcess returned %d", cmdRet);
|
||||
result = true;
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nProcess returned %d\n", cmdRet);
|
||||
result = (expectedResult == IGNORE_CMD_RESULT_VALUE || expectedResult == cmdRet);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -219,7 +219,8 @@ FTPClientThread::FTPClientThread(int portNumber, string serverUrl,
|
|||
FTPClientCallbackInterface *pCBObject,
|
||||
string fileArchiveExtension,
|
||||
string fileArchiveExtractCommand,
|
||||
string fileArchiveExtractCommandParameters) : BaseThread() {
|
||||
string fileArchiveExtractCommandParameters,
|
||||
int fileArchiveExtractCommandSuccessResult) : BaseThread() {
|
||||
this->portNumber = portNumber;
|
||||
this->serverUrl = serverUrl;
|
||||
this->mapsPath = mapsPath;
|
||||
|
@ -231,6 +232,7 @@ FTPClientThread::FTPClientThread(int portNumber, string serverUrl,
|
|||
this->fileArchiveExtension = fileArchiveExtension;
|
||||
this->fileArchiveExtractCommand = fileArchiveExtractCommand;
|
||||
this->fileArchiveExtractCommandParameters = fileArchiveExtractCommandParameters;
|
||||
this->fileArchiveExtractCommandSuccessResult = fileArchiveExtractCommandSuccessResult;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line %d] Using FTP port #: %d, serverUrl [%s]\n",__FILE__,__FUNCTION__,__LINE__,portNumber,serverUrl.c_str());
|
||||
}
|
||||
|
@ -413,7 +415,7 @@ void FTPClientThread::addFileToRequests(string fileName,string URL) {
|
|||
}
|
||||
|
||||
void FTPClientThread::getTilesetFromServer(pair<string,string> tileSetName) {
|
||||
bool findArchive = executeShellCommand(this->fileArchiveExtractCommand);
|
||||
bool findArchive = executeShellCommand(this->fileArchiveExtractCommand,this->fileArchiveExtractCommandSuccessResult);
|
||||
|
||||
pair<FTP_Client_ResultType,string> result = make_pair(ftp_crt_FAIL,"");
|
||||
if(tileSetName.second != "") {
|
||||
|
@ -676,7 +678,7 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getTilesetFromServer(pair<st
|
|||
this->fileArchiveExtractCommandParameters, destRootArchiveFolder,
|
||||
destRootArchiveFolder + tileSetName.first + this->fileArchiveExtension);
|
||||
|
||||
if(executeShellCommand(extractCmd) == false) {
|
||||
if(executeShellCommand(extractCmd,this->fileArchiveExtractCommandSuccessResult) == false) {
|
||||
result.first = ftp_crt_FAIL;
|
||||
result.second = "failed to extract arhcive!";
|
||||
}
|
||||
|
@ -730,7 +732,7 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getTilesetFromServer(pair<st
|
|||
|
||||
void FTPClientThread::getTechtreeFromServer(pair<string,string> techtreeName) {
|
||||
pair<FTP_Client_ResultType,string> result = make_pair(ftp_crt_FAIL,"");
|
||||
bool findArchive = executeShellCommand(this->fileArchiveExtractCommand);
|
||||
bool findArchive = executeShellCommand(this->fileArchiveExtractCommand,this->fileArchiveExtractCommandSuccessResult);
|
||||
if(findArchive == true) {
|
||||
if(techtreeName.second != "") {
|
||||
result = getTechtreeFromServer(techtreeName, "", "");
|
||||
|
@ -905,7 +907,7 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getTechtreeFromServer(pair<
|
|||
this->fileArchiveExtractCommandParameters, destRootArchiveFolder,
|
||||
destRootArchiveFolder + techtreeName.first + this->fileArchiveExtension);
|
||||
|
||||
if(executeShellCommand(extractCmd) == false) {
|
||||
if(executeShellCommand(extractCmd,this->fileArchiveExtractCommandSuccessResult) == false) {
|
||||
result.first = ftp_crt_FAIL;
|
||||
result.second = "failed to extract archive!";
|
||||
}
|
||||
|
@ -917,7 +919,7 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getTechtreeFromServer(pair<
|
|||
|
||||
void FTPClientThread::getScenarioFromServer(pair<string,string> fileName) {
|
||||
pair<FTP_Client_ResultType,string> result = make_pair(ftp_crt_FAIL,"");
|
||||
bool findArchive = executeShellCommand(this->fileArchiveExtractCommand);
|
||||
bool findArchive = executeShellCommand(this->fileArchiveExtractCommand,this->fileArchiveExtractCommandSuccessResult);
|
||||
if(findArchive == true) {
|
||||
result = getScenarioInternalFromServer(fileName);
|
||||
}
|
||||
|
@ -956,7 +958,7 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getScenarioInternalFromServ
|
|||
this->fileArchiveExtractCommandParameters, destRootArchiveFolder,
|
||||
destRootArchiveFolder + fileName.first + this->fileArchiveExtension);
|
||||
|
||||
if(executeShellCommand(extractCmd) == false) {
|
||||
if(executeShellCommand(extractCmd,this->fileArchiveExtractCommandSuccessResult) == false) {
|
||||
result.first = ftp_crt_FAIL;
|
||||
result.second = "failed to extract archive!";
|
||||
}
|
||||
|
@ -972,7 +974,7 @@ void FTPClientThread::getFileFromServer(pair<string,string> fileName) {
|
|||
bool findArchive = true;
|
||||
string ext = extractExtension(fileName.first);
|
||||
if(ext == "7z") {
|
||||
findArchive = executeShellCommand(this->fileArchiveExtractCommand);
|
||||
findArchive = executeShellCommand(this->fileArchiveExtractCommand,this->fileArchiveExtractCommandSuccessResult);
|
||||
}
|
||||
if(findArchive == true) {
|
||||
result = getFileInternalFromServer(fileName);
|
||||
|
@ -1020,7 +1022,7 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getFileInternalFromServer(p
|
|||
this->fileArchiveExtractCommandParameters, destRootArchiveFolder,
|
||||
destFileSaveAs);
|
||||
|
||||
if(executeShellCommand(extractCmd) == false) {
|
||||
if(executeShellCommand(extractCmd,this->fileArchiveExtractCommandSuccessResult) == false) {
|
||||
result.first = ftp_crt_FAIL;
|
||||
result.second = "failed to extract archive!";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue