mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 21:11:39 +00:00
Changed: Remember startup path (the initial current directory)
This commit is contained in:
parent
7737c1c0df
commit
a91fa58656
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
|
/// Returns program name or path passed as first parameter to parse() method
|
||||||
std::string getProgramName() const { return _ProgramName; }
|
std::string getProgramName() const { return _ProgramName; }
|
||||||
std::string getProgramPath() const { return _ProgramPath; }
|
std::string getProgramPath() const { return _ProgramPath; }
|
||||||
|
std::string getStartupPath() const { return _StartupPath; }
|
||||||
|
|
||||||
/// Set or get description to display in help
|
/// Set or get description to display in help
|
||||||
void setDescription(const std::string &description) { _Description = description; }
|
void setDescription(const std::string &description) { _Description = description; }
|
||||||
|
@ -129,6 +130,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
std::string _ProgramName; // filename of the program
|
std::string _ProgramName; // filename of the program
|
||||||
std::string _ProgramPath; // full path 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 _Description; // description of the program
|
||||||
std::string _Version; // version 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());
|
_ProgramName = CFile::getFilename(argv.front());
|
||||||
_ProgramPath = CPath::makePathAbsolute(CPath::standardizePath(CFile::getPath(argv.front())), CPath::getCurrentPath(), true);
|
_ProgramPath = CPath::makePathAbsolute(CPath::standardizePath(CFile::getPath(argv.front())), CPath::getCurrentPath(), true);
|
||||||
|
|
||||||
|
// current path
|
||||||
|
_StartupPath = CPath::standardizePath(CPath::getCurrentPath());
|
||||||
|
|
||||||
// set process name for logs
|
// set process name for logs
|
||||||
CLog::setProcessName(_ProgramName);
|
CLog::setProcessName(_ProgramName);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "nel/misc/config_file.h"
|
#include "nel/misc/config_file.h"
|
||||||
#include "nel/misc/bit_mem_stream.h"
|
#include "nel/misc/bit_mem_stream.h"
|
||||||
#include "nel/misc/i18n.h"
|
#include "nel/misc/i18n.h"
|
||||||
|
#include "nel/misc/cmd_args.h"
|
||||||
// Client.
|
// Client.
|
||||||
#include "client_cfg.h"
|
#include "client_cfg.h"
|
||||||
#include "entities.h"
|
#include "entities.h"
|
||||||
|
@ -256,6 +257,8 @@ extern string Cookie;
|
||||||
extern string FSAddr;
|
extern string FSAddr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern NLMISC::CCmdArgs Args;
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
// METHODS //
|
// METHODS //
|
||||||
/////////////
|
/////////////
|
||||||
|
@ -2224,7 +2227,11 @@ bool CClientConfig::getDefaultConfigLocation(std::string& p_name) const
|
||||||
if (CFile::isExists(defaultConfigFileName))
|
if (CFile::isExists(defaultConfigFileName))
|
||||||
p_name = 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))
|
else if (CFile::isExists(defaultConfigPath + defaultConfigFileName))
|
||||||
p_name = 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
|
// current directory has priority everywhere
|
||||||
directoryPrefixes.push_back(CPath::standardizePath(CPath::getCurrentPath()));
|
directoryPrefixes.push_back(CPath::standardizePath(CPath::getCurrentPath()));
|
||||||
|
|
||||||
|
// startup directory
|
||||||
|
directoryPrefixes.push_back(Args.getStartupPath());
|
||||||
|
|
||||||
#if defined(NL_OS_WINDOWS)
|
#if defined(NL_OS_WINDOWS)
|
||||||
// check in same directory as executable
|
// check in same directory as executable
|
||||||
directoryPrefixes.push_back(Args.getProgramPath());
|
directoryPrefixes.push_back(Args.getProgramPath());
|
||||||
|
|
Loading…
Reference in a new issue