Changed: Minor changes

--HG--
branch : compatibility
This commit is contained in:
kervala 2014-03-23 20:36:46 +01:00
parent a62393a9ed
commit 8adf6df76a

View file

@ -34,8 +34,8 @@
#ifdef USE_CURL #ifdef USE_CURL
#include <curl/curl.h> #include <curl/curl.h>
#endif #endif
#include <zlib.h>
#include <zlib.h>
#include "nel/misc/debug.h" #include "nel/misc/debug.h"
#include "nel/misc/path.h" #include "nel/misc/path.h"
@ -68,7 +68,7 @@
#endif #endif
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
#include <direct.h> #include <direct.h>
#endif #endif
// //
@ -87,11 +87,12 @@ extern string VersionName;
extern string R2ServerVersion; extern string R2ServerVersion;
#ifdef __CLIENT_INSTALL_EXE__ #ifdef __CLIENT_INSTALL_EXE__
extern std::string TheTmpInstallDirectory; extern std::string TheTmpInstallDirectory;
extern std::string ClientLauncherUrl; extern std::string ClientLauncherUrl;
#else #else
std::string TheTmpInstallDirectory ="patch/client_install"; std::string TheTmpInstallDirectory = "patch/client_install";
#endif #endif
// **************************************************************************** // ****************************************************************************
// **************************************************************************** // ****************************************************************************
// **************************************************************************** // ****************************************************************************
@ -259,16 +260,20 @@ void CPatchManager::init(const std::vector<std::string>& patchURIs, const std::s
try try
{ {
CConfigFile *cf; CConfigFile *cf;
#ifdef RY_BG_DOWNLOADER
#ifdef RY_BG_DOWNLOADER
cf = &theApp.ConfigFile; cf = &theApp.ConfigFile;
#else #else
cf = &ClientCfg.ConfigFile; cf = &ClientCfg.ConfigFile;
#endif #endif
std::string appName = "ryzom_live"; std::string appName = "ryzom_live";
if (cf->getVarPtr("Application")) if (cf->getVarPtr("Application"))
{ {
appName = cf->getVar("Application").asString(0); appName = cf->getVar("Application").asString(0);
} }
std::string versionFileName = appName + ".version"; std::string versionFileName = appName + ".version";
getServerFile(versionFileName); getServerFile(versionFileName);
@ -280,13 +285,14 @@ void CPatchManager::init(const std::vector<std::string>& patchURIs, const std::s
versionFile.getline(buffer, 1024); versionFile.getline(buffer, 1024);
CSString line(buffer); CSString line(buffer);
#ifdef NL_DEBUG #ifdef NL_DEBUG
CConfigFile::CVar *forceVersion = cf->getVarPtr("ForceVersion"); CConfigFile::CVar *forceVersion = cf->getVarPtr("ForceVersion");
if (forceVersion != NULL) if (forceVersion != NULL)
{ {
line = forceVersion->asString(); line = forceVersion->asString();
} }
#endif #endif
ServerVersion = line.firstWord(true); ServerVersion = line.firstWord(true);
VersionName = line.firstWord(true); VersionName = line.firstWord(true);
@ -294,7 +300,7 @@ void CPatchManager::init(const std::vector<std::string>& patchURIs, const std::s
// force the R2ServerVersion // force the R2ServerVersion
R2ServerVersion = ServerVersion; R2ServerVersion = ServerVersion;
#ifdef __CLIENT_INSTALL_EXE__ #ifdef __CLIENT_INSTALL_EXE__
{ {
//The install program load a the url of the mini web site in the patch directory //The install program load a the url of the mini web site in the patch directory
@ -332,7 +338,7 @@ void CPatchManager::init(const std::vector<std::string>& patchURIs, const std::s
} }
} }
} }
#endif #endif
} }
catch (...) catch (...)
{ {
@ -740,6 +746,7 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
string err = toString("Can't open file '%s' for writing: code=%d %s (error code 29)", UpdateBatchFilename.c_str(), errno, strerror(errno)); string err = toString("Can't open file '%s' for writing: code=%d %s (error code 29)", UpdateBatchFilename.c_str(), errno, strerror(errno));
throw Exception (err); throw Exception (err);
} }
//use bat if windows if not use sh //use bat if windows if not use sh
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
fprintf(fp, "@echo off\n"); fprintf(fp, "@echo off\n");
@ -777,6 +784,7 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
throw; throw;
} }
if (!result) if (!result)
{ {
//:TODO: handle exception? //:TODO: handle exception?
@ -796,19 +804,17 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
string SrcPath = ClientPatchPath; string SrcPath = ClientPatchPath;
string DstPath = rCat.getUnpackTo(); string DstPath = rCat.getUnpackTo();
NLMISC::CFile::createDirectoryTree(DstPath); NLMISC::CFile::createDirectoryTree(DstPath);
// this file must be moved
// this file must be moved
if (useBatchFile) if (useBatchFile)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
SrcPath = CPath::standardizeDosPath(SrcPath); SrcPath = CPath::standardizeDosPath(SrcPath);
DstPath = CPath::standardizeDosPath(DstPath); DstPath = CPath::standardizeDosPath(DstPath);
#elif NL_OS_MAC #else
//no patcher on mac yet
#else
SrcPath = CPath::standardizePath(SrcPath); SrcPath = CPath::standardizePath(SrcPath);
DstPath = CPath::standardizePath(DstPath); DstPath = CPath::standardizePath(DstPath);
#endif #endif
} }
std::string SrcName = SrcPath + vFilenames[fff]; std::string SrcName = SrcPath + vFilenames[fff];
@ -843,26 +849,25 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
// Finalize batch file // Finalize batch file
if (NLMISC::CFile::isExists("patch") && NLMISC::CFile::isDirectory("patch")) if (NLMISC::CFile::isExists("patch") && NLMISC::CFile::isDirectory("patch"))
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
if (useBatchFile) if (useBatchFile)
{ {
fprintf(fp, ":looppatch\n"); fprintf(fp, ":looppatch\n");
} }
#endif #endif
vector<string> vFileList; vector<string> vFileList;
CPath::getPathContent ("patch", false, false, true, vFileList, NULL, false); CPath::getPathContent ("patch", false, false, true, vFileList, NULL, false);
for(uint32 i = 0; i < vFileList.size(); ++i) for(uint32 i = 0; i < vFileList.size(); ++i)
{ {
if (useBatchFile) if (useBatchFile)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
fprintf(fp, "del %s\n", CPath::standardizeDosPath(vFileList[i]).c_str()); fprintf(fp, "del %s\n", CPath::standardizeDosPath(vFileList[i]).c_str());
#elif NL_OS_MAC #else
//no patcher on MAC yet
#else
fprintf(fp, "rm -f %s\n", CPath::standardizePath(vFileList[i]).c_str()); fprintf(fp, "rm -f %s\n", CPath::standardizePath(vFileList[i]).c_str());
#endif #endif
} }
else else
{ {
@ -872,14 +877,12 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
if (useBatchFile) if (useBatchFile)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
fprintf(fp, "rd /Q /S patch\n"); fprintf(fp, "rd /Q /S patch\n");
fprintf(fp, "if exist patch goto looppatch\n"); fprintf(fp, "if exist patch goto looppatch\n");
#elif NL_OS_MAC #else
//no patcher on mac yet
#else
fprintf(fp, "rm -rf patch\n"); fprintf(fp, "rm -rf patch\n");
#endif #endif
} }
else else
{ {
@ -891,11 +894,11 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
{ {
if (wantRyzomRestart) if (wantRyzomRestart)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
fprintf(fp, "start %s %%1 %%2 %%3\n", RyzomFilename.c_str()); fprintf(fp, "start %s %%1 %%2 %%3\n", RyzomFilename.c_str());
#else #else
fprintf(fp, "%s $1 $2 $3\n", RyzomFilename.c_str()); fprintf(fp, "%s $1 $2 $3\n", RyzomFilename.c_str());
#endif #endif
} }
bool writeError = ferror(fp) != 0; bool writeError = ferror(fp) != 0;
@ -970,9 +973,11 @@ void CPatchManager::executeBatchFile()
#else #else
// Start the child process. // Start the child process.
bool r2Mode = false; bool r2Mode = false;
#ifndef RY_BG_DOWNLOADER
#ifndef RY_BG_DOWNLOADER
r2Mode = ClientCfg.R2Mode; r2Mode = ClientCfg.R2Mode;
#endif #endif
string strCmdLine; string strCmdLine;
strCmdLine = "./" + UpdateBatchFilename; strCmdLine = "./" + UpdateBatchFilename;
@ -1318,7 +1323,7 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de
DownloadInProgress = true; DownloadInProgress = true;
try try
{ {
#ifdef USE_CURL #ifdef USE_CURL
ucstring s = CI18N::get("uiDLWithCurl") + " " + dest; ucstring s = CI18N::get("uiDLWithCurl") + " " + dest;
setState(true, s); setState(true, s);
@ -1415,9 +1420,9 @@ void CPatchManager::downloadFileWithCurl (const string &source, const string &de
throw EPatchDownloadException (NLMISC::toString("curl download failed: (ec %d %d)", res, r)); throw EPatchDownloadException (NLMISC::toString("curl download failed: (ec %d %d)", res, r));
} }
#else #else
throw Exception("USE_CURL is not defined, no curl method"); throw Exception("USE_CURL is not defined, no curl method");
#endif #endif
} }
catch(...) catch(...)
{ {
@ -2132,9 +2137,7 @@ void CPatchManager::getCorruptedFileInfo(const SFileToPatch &ftp, ucstring &sTra
bool CPatchManager::unpack7Zip(const std::string &sevenZipFile, const std::string &destFileName) bool CPatchManager::unpack7Zip(const std::string &sevenZipFile, const std::string &destFileName)
{ {
#ifdef RZ_USE_SEVENZIP #ifdef RZ_USE_SEVENZIP
nlinfo("Uncompressing 7zip archive '%s' to '%s'", nlinfo("Uncompressing 7zip archive '%s' to '%s'", sevenZipFile.c_str(), destFileName.c_str());
sevenZipFile.c_str(),
destFileName.c_str());
// init seven zip // init seven zip
ISzAlloc allocImp; ISzAlloc allocImp;