From a4d98fb13bb527c32ab94f2aef4ebceab6f10480 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 13 Feb 2016 23:29:00 +0100 Subject: [PATCH] Changed: Remember startup path (the initial current directory) --HG-- branch : develop --- code/nel/include/nel/misc/cmd_args.h | 2 ++ code/nel/src/misc/cmd_args.cpp | 3 +++ code/ryzom/client/src/client_cfg.cpp | 9 ++++++++- code/ryzom/client/src/init.cpp | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/misc/cmd_args.h b/code/nel/include/nel/misc/cmd_args.h index 25195b64d..3fb87e0c0 100644 --- a/code/nel/include/nel/misc/cmd_args.h +++ b/code/nel/include/nel/misc/cmd_args.h @@ -118,6 +118,7 @@ public: /// Returns program name or path passed as first parameter to parse() method std::string getProgramName() const { return _ProgramName; } std::string getProgramPath() const { return _ProgramPath; } + std::string getStartupPath() const { return _StartupPath; } /// Set or get description to display in help void setDescription(const std::string &description) { _Description = description; } @@ -129,6 +130,7 @@ public: protected: std::string _ProgramName; // filename of the program std::string _ProgramPath; // full path of the program + std::string _StartupPath; // initial startup path std::string _Description; // description of the program std::string _Version; // version of the program diff --git a/code/nel/src/misc/cmd_args.cpp b/code/nel/src/misc/cmd_args.cpp index 11464b222..85239e8ff 100644 --- a/code/nel/src/misc/cmd_args.cpp +++ b/code/nel/src/misc/cmd_args.cpp @@ -264,6 +264,9 @@ bool CCmdArgs::parse(const std::vector &argv) _ProgramName = CFile::getFilename(argv.front()); _ProgramPath = CPath::makePathAbsolute(CPath::standardizePath(CFile::getPath(argv.front())), CPath::getCurrentPath(), true); + // current path + _StartupPath = CPath::standardizePath(CPath::getCurrentPath()); + // set process name for logs CLog::setProcessName(_ProgramName); diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index 2e1bbdca4..3f28c0458 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -25,6 +25,7 @@ #include "nel/misc/config_file.h" #include "nel/misc/bit_mem_stream.h" #include "nel/misc/i18n.h" +#include "nel/misc/cmd_args.h" // Client. #include "client_cfg.h" #include "entities.h" @@ -256,6 +257,8 @@ extern string Cookie; extern string FSAddr; #endif +extern NLMISC::CCmdArgs Args; + ///////////// // METHODS // ///////////// @@ -2224,7 +2227,11 @@ bool CClientConfig::getDefaultConfigLocation(std::string& p_name) const if (CFile::isExists(defaultConfigFileName)) p_name = defaultConfigFileName; - // if not in working directory, check using prefix path + // look in startup directory + else if (CFile::isExists(Args.getStartupPath() + defaultConfigFileName)) + p_name = Args.getStartupPath() + defaultConfigFileName; + + // look in prefix path else if (CFile::isExists(defaultConfigPath + defaultConfigFileName)) p_name = defaultConfigPath + defaultConfigFileName; diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 828506c2d..c0df71a43 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -661,6 +661,9 @@ static void addPaths(IProgressCallback &progress, const std::vector // current directory has priority everywhere directoryPrefixes.push_back(CPath::standardizePath(CPath::getCurrentPath())); + // startup directory + directoryPrefixes.push_back(Args.getStartupPath()); + #if defined(NL_OS_WINDOWS) // check in same directory as executable directoryPrefixes.push_back(Args.getProgramPath());