mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-31 06:35:03 +01:00
set application.configDir property correctly if a configuration file is explicitely loaded and no default config file is found.
This commit is contained in:
parent
2711037d4e
commit
4bf0328740
@ -389,6 +389,7 @@ private:
|
||||
Poco::Logger* _pLogger;
|
||||
Poco::Timestamp _startTime;
|
||||
bool _stopOptionsProcessing;
|
||||
int _loadedConfigs;
|
||||
|
||||
#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS)
|
||||
std::string _workingDirAtLaunch;
|
||||
|
@ -71,7 +71,8 @@ Application::Application():
|
||||
_initialized(false),
|
||||
_unixOptions(true),
|
||||
_pLogger(&Logger::get("ApplicationStartup")),
|
||||
_stopOptionsProcessing(false)
|
||||
_stopOptionsProcessing(false),
|
||||
_loadedConfigs(0)
|
||||
{
|
||||
setup();
|
||||
}
|
||||
@ -82,7 +83,8 @@ Application::Application(int argc, char* argv[]):
|
||||
_initialized(false),
|
||||
_unixOptions(true),
|
||||
_pLogger(&Logger::get("ApplicationStartup")),
|
||||
_stopOptionsProcessing(false)
|
||||
_stopOptionsProcessing(false),
|
||||
_loadedConfigs(0)
|
||||
{
|
||||
setup();
|
||||
init(argc, argv);
|
||||
@ -253,13 +255,14 @@ int Application::loadConfiguration(int priority)
|
||||
++n;
|
||||
}
|
||||
#endif
|
||||
if (n > 0)
|
||||
if (n > 0 && _loadedConfigs == 0)
|
||||
{
|
||||
if (!confPath.isAbsolute())
|
||||
_pConfig->setString("application.configDir", confPath.absolute().parent().toString());
|
||||
else
|
||||
_pConfig->setString("application.configDir", confPath.parent().toString());
|
||||
}
|
||||
_loadedConfigs += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -297,13 +300,14 @@ void Application::loadConfiguration(const std::string& path, int priority)
|
||||
#endif
|
||||
else throw Poco::InvalidArgumentException("Unsupported configuration file type", ext);
|
||||
|
||||
if (n > 0 && !_pConfig->has("application.configDir"))
|
||||
if (n > 0 && _loadedConfigs == 0)
|
||||
{
|
||||
if (!confPath.isAbsolute())
|
||||
_pConfig->setString("application.configDir", confPath.absolute().parent().toString());
|
||||
else
|
||||
_pConfig->setString("application.configDir", confPath.parent().toString());
|
||||
}
|
||||
_loadedConfigs += n;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user