1 #ifndef __VLP_CONFIGURATIONFINDER_H
2 #define __VLP_CONFIGURATIONFINDER_H
11 * @brief Configuration file finding utilities
12 * @author Rafał Długołęcki
18 #if defined(WIN32) || defined(_WIN32)
19 # define VLP_CONFIG_PATH_SEPARATOR "\\"
21 # define VLP_CONFIG_PATH_SEPARATOR "/"
24 class ConfigurationFinder {
26 std::vector<std::string> searchDirs;
29 * Adds directory to the list of search directories
31 void addSearchDir(std::string dir);
34 * Default name of configuration file
36 static const constexpr char * DEFAULT_CONFIG_FILENAME = "vlp.cfg";
38 ConfigurationFinder();
41 * Initializes list of search directories
43 void initSearchDirs();
46 * Finds config file in possible config directories
48 * Search is made in following steps:
49 * 1. Check existence of filename in current execution path dir
50 * 2. If not found, check in user home directory, e.g:
51 * - C:/Documents and Settings/Username
53 * 3. If not found, check in system config directory (build dependent),
55 * - /usr/local/etc/loglan/
58 * @param filename name of the file to search for
59 * @return path to the filename
62 std::string findConfig(std::string filename = DEFAULT_CONFIG_FILENAME);
65 * Gets path to user local settings directory
67 * @return directory of user settings
69 virtual std::string getUserConfigurationDir() = 0;
72 * Gets path to system-wide settings directory
74 * @return directory of user settings
76 std::string getSystemConfigurationDir();
83 #endif /* __VLP_CONFIGURATIONFINDER_H */