xale-db 1.0
minimal SQL engine, written in c++
Loading...
Searching...
No Matches
ConfigurationPath.h
Go to the documentation of this file.
1#ifndef CORE_CONFIGURATION_PATH_H
2#define CORE_CONFIGURATION_PATH_H
3
4#include <string>
5#include <filesystem>
6
7constexpr auto XALE_CONFIG_DEFAULT_FILE_NAME = "appconfig.json";
8
10{
11 inline std::string getExecutableFolderPath()
12 {
13 namespace fs = std::filesystem;
14 std::error_code ec;
15
16#if defined(__linux__) || defined(linux) || defined(__GNUG__)
17 fs::path exe = fs::canonical("/proc/self/exe", ec);
18 std::string path = exe.parent_path().string();
19#else
20 fs::path exe = fs::current_path(ec);
21 std::string path = exe.string();
22#endif
23 if (ec)
24 return {};
25
26 return path;
27 }
28
29 inline std::string getConfigPath(std::string configFileName = XALE_CONFIG_DEFAULT_FILE_NAME)
30 {
31 return (getExecutableFolderPath() + "/" + configFileName);
32 }
33}
34
35#endif // CORE_CONFIGURATION_PATH_H
constexpr auto XALE_CONFIG_DEFAULT_FILE_NAME
Definition ConfigurationPath.h:7
Definition ConfigurationPath.h:10
std::string getExecutableFolderPath()
Definition ConfigurationPath.h:11
std::string getConfigPath(std::string configFileName=XALE_CONFIG_DEFAULT_FILE_NAME)
Definition ConfigurationPath.h:29