diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-03-04 15:23:28 -0800 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-03-26 07:46:03 -0500 |
commit | 8055879242b43500c49e8ea8d4035687d13f9fae (patch) | |
tree | 24605e64cfd02f55959d166a23836f78ab66a644 /host/lib/utils | |
parent | 39d6007ca7e3b27e8230db6690faa7469ca62cb2 (diff) | |
download | uhd-8055879242b43500c49e8ea8d4035687d13f9fae.tar.gz uhd-8055879242b43500c49e8ea8d4035687d13f9fae.tar.bz2 uhd-8055879242b43500c49e8ea8d4035687d13f9fae.zip |
uhd: paths: Add get_cal_data_path() API call
This points to the location where cal data is stored.
Diffstat (limited to 'host/lib/utils')
-rw-r--r-- | host/lib/utils/paths.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
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<fs::path> uhd::get_module_paths(void) { |