mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-23 07:36:16 +00:00
Changed: Remember startup path (the initial current directory)
--HG-- branch : develop
This commit is contained in:
parent
5d44cc4075
commit
a4d98fb13b
4 changed files with 16 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -264,6 +264,9 @@ bool CCmdArgs::parse(const std::vector<std::string> &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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -661,6 +661,9 @@ static void addPaths(IProgressCallback &progress, const std::vector<std::string>
|
|||
// 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());
|
||||
|
|
Loading…
Reference in a new issue