lib: remove mu-runtime

Remove runtime; update the logger for that, and move the runtime-paths
stuff to utils.
This commit is contained in:
Dirk-Jan C. Binnema
2022-11-16 19:03:36 +02:00
parent b0fad6d763
commit 64f08149bc
8 changed files with 122 additions and 257 deletions

View File

@ -638,3 +638,36 @@ Mu::timezone_available(const std::string& tz)
return have_tz;
}
std::string
Mu::runtime_path(Mu::RuntimePath path, const std::string& muhome)
{
auto [mu_cache, mu_config] =
std::invoke([&]()->std::pair<std::string, std::string> {
static std::string mu{"/mu"};
if (muhome.empty())
return { g_get_user_cache_dir() + mu,
g_get_user_config_dir() + mu };
else
return { muhome, muhome };
});
switch (path) {
case Mu::RuntimePath::Cache:
return mu_cache;
case Mu::RuntimePath::XapianDb:
return mu_cache + "/xapian";
case Mu::RuntimePath::LogFile:
return mu_cache + "/mu.log";
case Mu::RuntimePath::Bookmarks:
return mu_config + "/bookmarks";
case Mu::RuntimePath::Config:
return mu_config;
case Mu::RuntimePath::Scripts:
return mu_config + "/scripts";
default:
throw std::logic_error("unknown path");
}
}