From 8055879242b43500c49e8ea8d4035687d13f9fae Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 4 Mar 2020 15:23:28 -0800 Subject: uhd: paths: Add get_cal_data_path() API call This points to the location where cal data is stored. --- host/lib/utils/paths.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'host/lib/utils/paths.cpp') diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 326551c8c..ccf52f257 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -214,6 +214,25 @@ std::string uhd::get_lib_path(void) } #endif +std::string uhd::get_cal_data_path(void) +{ + const std::string uhdcalib_path = get_env_var("UHD_CAL_DATA_PATH"); + if (not uhdcalib_path.empty()) { + return uhdcalib_path; + } + + std::string xdg_data_home_str = get_env_var("XDG_DATA_HOME", ""); + fs::path xdg_data_home(xdg_data_home_str); + if (xdg_data_home_str.empty()) { + const std::string home = get_env_var("HOME", ""); + xdg_data_home = fs::path(home) / ".local" / "share"; + } + + // FIXME: This needs to check if paths make sense, work on Windows, etc. + + fs::path cal_data_path = fs::path(xdg_data_home) / "uhd" / "cal_data"; + return cal_data_path.string(); +} std::vector uhd::get_module_paths(void) { -- cgit v1.2.3