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