MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getClientConfigPath

Function getClientConfigPath

src/Common/Config/getClientConfigPath.cpp:13–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11{
12
13std::optional<std::string> getClientConfigPath(const std::string & home_path)
14{
15 std::string config_path;
16
17 std::vector<std::string> names;
18 names.emplace_back("./clickhouse-client");
19
20 auto xdg_config_home = XDGBaseDirectories::getConfigurationHome();
21 if (!xdg_config_home.empty())
22 names.emplace_back(xdg_config_home / "config");
23
24 if (!home_path.empty())
25 names.emplace_back(home_path + "/.clickhouse-client/config");
26
27 names.emplace_back("/etc/clickhouse-client/config");
28
29 for (const auto & name : names)
30 {
31 for (const auto & extension : {".xml", ".yaml", ".yml"})
32 {
33 config_path = name + extension;
34
35 std::error_code ec;
36 if (fs::exists(config_path, ec))
37 return config_path;
38 }
39 }
40
41 return std::nullopt;
42}
43
44}

Callers 2

initializeMethod · 0.85
initializeMethod · 0.85

Calls 3

existsFunction · 0.50
emplace_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected