diff options
author | Peter Powell <petpow@saberuk.com> | 2013-07-10 18:11:48 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2013-08-12 16:53:33 +0100 |
commit | 29822a263b3b408559257e9ef2bd29167e7573fa (patch) | |
tree | 85a67980fb21b7a61756761558fef396adad7dd7 /include | |
parent | 3d019b14ec0025ff38bbd40c868ddccd0b13d8a3 (diff) |
Add <path> keys for all of the compile-time paths.
Also, make all paths in the config relative to their associated
directory. This reverts a change in 2.0 which turned out to be a
terrible idea, especially for system-wide installations.
Diffstat (limited to 'include')
-rw-r--r-- | include/configreader.h | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/include/configreader.h b/include/configreader.h index 0d514e41d..bf5acbbc8 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -184,6 +184,32 @@ class CoreExport ServerConfig void CrossCheckConnectBlocks(ServerConfig* current); public: + class ServerPaths + { + public: + /** Config path */ + std::string Config; + + /** Data path */ + std::string Data; + + /** Log path */ + std::string Log; + + /** Module path */ + std::string Module; + + ServerPaths() + : Config(CONFIG_PATH) + , Data(DATA_PATH) + , Log(LOG_PATH) + , Module(MOD_PATH) { } + + std::string PrependConfig(const std::string& fn) const { return ServerConfig::ExpandPath(Config, fn); } + std::string PrependData(const std::string& fn) const { return ServerConfig::ExpandPath(Data, fn); } + std::string PrependLog(const std::string& fn) const { return ServerConfig::ExpandPath(Log, fn); } + std::string PrependModule(const std::string& fn) const { return ServerConfig::ExpandPath(Module, fn); } + }; /** Get a configuration tag * @param tag The name of the tag to get @@ -220,6 +246,9 @@ class CoreExport ServerConfig */ ServerLimits Limits; + /** Locations of various types of file (config, module, etc). */ + ServerPaths Paths; + /** Configuration parsed from the command line. */ CommandLineConf cmdline; @@ -333,13 +362,6 @@ class CoreExport ServerConfig */ char DisabledCModes[64]; - /** The full path to the modules directory. - * This is either set at compile time, or - * overridden in the configuration file via - * the \<path> tag. - */ - std::string ModPath; - /** If set to true, then all opers on this server are * shown with a generic 'is an IRC operator' line rather * than the oper type. Oper types are still used internally. @@ -508,7 +530,7 @@ class CoreExport ServerConfig /** Returns true if the given string starts with a windows drive letter */ - bool StartsWithWindowsDriveLetter(const std::string &path); + static bool StartsWithWindowsDriveLetter(const std::string& path); bool ApplyDisabledCommands(const std::string& data); @@ -523,7 +545,13 @@ class CoreExport ServerConfig * @return True if the file exists and is readable. */ static bool FileExists(const char* file); - + + /** Expands a path fragment to a full path. + * @param base The base path to expand from + * @param fragment The path fragment to expand on top of base. + */ + static std::string ExpandPath(const std::string& base, const std::string& fragment); + /** Escapes a value for storage in a configuration key. * @param str The string to escape. * @param xml Are we using the XML config format? |