refactor data directory
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
Scott E. Graves 2025-02-27 21:09:47 -06:00
parent 9f90494efb
commit 86918595b3
3 changed files with 26 additions and 22 deletions

View File

@ -46,6 +46,8 @@ public:
[[nodiscard]] static auto default_rpc_port(const provider_type &prov) [[nodiscard]] static auto default_rpc_port(const provider_type &prov)
-> std::uint16_t; -> std::uint16_t;
[[nodiscard]] static auto get_data_directory() -> std::string;
[[nodiscard]] static auto get_provider_display_name(const provider_type &prov) [[nodiscard]] static auto get_provider_display_name(const provider_type &prov)
-> std::string; -> std::string;

View File

@ -699,36 +699,38 @@ auto app_config::default_api_port(const provider_type &prov) -> std::uint16_t {
return PROVIDER_API_PORTS.at(static_cast<std::size_t>(prov)); return PROVIDER_API_PORTS.at(static_cast<std::size_t>(prov));
} }
auto app_config::default_data_directory(const provider_type &prov) auto app_config::get_data_directory() -> std::string {
-> std::string {
#if defined(_WIN32) #if defined(_WIN32)
auto data_directory = auto data_directory = utils::path::combine(
utils::path::combine(utils::get_local_app_data_directory(), utils::get_local_app_data_directory(), {
{ REPERTORY_DATA_NAME,
REPERTORY_DATA_NAME, });
app_config::get_provider_name(prov),
});
#else // !defined(_WIN32) #else // !defined(_WIN32)
#if defined(__APPLE__) #if defined(__APPLE__)
auto data_directory = auto data_directory = utils::path::combine("~", {
utils::path::combine("~", { "Library",
"Library", "Application Support",
"Application Support", REPERTORY_DATA_NAME,
REPERTORY_DATA_NAME, });
app_config::get_provider_name(prov),
});
#else // !defined(__APPLE__) #else // !defined(__APPLE__)
auto data_directory = auto data_directory = utils::path::combine("~", {
utils::path::combine("~", { ".local",
".local", REPERTORY_DATA_NAME,
REPERTORY_DATA_NAME, });
app_config::get_provider_name(prov),
});
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
#endif // defined(_WIN32) #endif // defined(_WIN32)
return data_directory; return data_directory;
} }
auto app_config::default_data_directory(const provider_type &prov)
-> std::string {
return utils::path::combine(app_config::get_data_directory(),
{
REPERTORY_DATA_NAME,
app_config::get_provider_name(prov),
});
}
auto app_config::default_remote_api_port(const provider_type &prov) auto app_config::default_remote_api_port(const provider_type &prov)
-> std::uint16_t { -> std::uint16_t {
static const std::array<std::uint16_t, static const std::array<std::uint16_t,

View File

@ -55,7 +55,7 @@ private:
httplib::Server *server_; httplib::Server *server_;
private: private:
console_consumer console{}; console_consumer console;
}; };
} // namespace repertory::ui } // namespace repertory::ui