mirror of
https://github.com/saymrwulf/uhd.git
synced 2026-05-14 20:58:09 +00:00
Up until now, we completely ignore the XDG specification.
This commit does the following to change that:
- It uses XDG_DATA_HOME and XDG_CONFIG_HOME for cal and config data,
respectively.
- If config data is in ~/.uhd/uhd.conf, that is still accepted, but if
it conflicts with $XDG_CONFIG_HOME/uhd.conf, it is ignored and a
warning is displayed
- The default location for cal data is thus ${HOME}/.local/share/uhd/cal
on Unix, and %LOCALAPPDATA%\uhd\cal on Windows. This is a change in
location!
- The UHD_CONFIG_DIR environment variable was confusingly named and is
now removed. It provided an alternative location than the home
directory. The same purpose is now much better served by XDG_DATA_HOME
and XDG_CONFIG_HOME.
The specification can be found here:
specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
68 lines
2.1 KiB
C++
68 lines
2.1 KiB
C++
//
|
|
// Copyright 2018 Ettus Research, a National Instruments Company
|
|
// Copyright 2019 Ettus Research, A National Instruments Brand
|
|
//
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
//
|
|
|
|
#include <uhd/config.hpp>
|
|
#include <uhd/exception.hpp>
|
|
#include <uhd/utils/paths.hpp>
|
|
#include <uhdlib/utils/paths.hpp>
|
|
#include <boost/filesystem/operations.hpp>
|
|
#include <boost/test/unit_test.hpp>
|
|
#include <iostream>
|
|
#include <vector>
|
|
|
|
BOOST_AUTO_TEST_CASE(test_paths_expandvars)
|
|
{
|
|
#ifdef UHD_PLATFORM_WIN32
|
|
const std::string path_to_expand("%programdata%/uhd/uhd.conf");
|
|
#else
|
|
const std::string path_to_expand("$HOME/.uhd/uhd.conf");
|
|
#endif
|
|
const std::string expanded_path = uhd::path_expandvars(path_to_expand);
|
|
|
|
std::cout << "Expanded path: " << path_to_expand << " -> " << expanded_path
|
|
<< std::endl;
|
|
BOOST_CHECK(path_to_expand != expanded_path);
|
|
|
|
#ifdef UHD_PLATFORM_WIN32
|
|
const std::string var_identifier = "%";
|
|
#else
|
|
const std::string var_identifier = "$";
|
|
#endif
|
|
|
|
BOOST_CHECK(expanded_path.find(var_identifier) == std::string::npos);
|
|
}
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_get_paths)
|
|
{
|
|
using namespace uhd;
|
|
|
|
std::cout << "tmp_path: " << get_tmp_path() << std::endl;
|
|
BOOST_CHECK(true);
|
|
std::cout << "pkg_path: " << get_pkg_path() << std::endl;
|
|
BOOST_CHECK(true);
|
|
std::cout << "cal_path: " << get_cal_data_path() << std::endl;
|
|
BOOST_CHECK(true);
|
|
|
|
const auto module_paths = get_module_paths();
|
|
for (const auto& module_path : module_paths) {
|
|
std::cout << "module path: " << module_path << std::endl;
|
|
}
|
|
BOOST_CHECK(true);
|
|
|
|
const std::string images_dir_search_path = "";
|
|
const std::string images_dir = get_images_dir(images_dir_search_path);
|
|
BOOST_REQUIRE_THROW(
|
|
find_image_path("this_device_does_not_exist.bit", ""), uhd::io_error);
|
|
|
|
const std::string utility_path = find_utility("uhd_images_downloader");
|
|
std::cout << "utility_path: " << utility_path << std::endl;
|
|
|
|
const std::string utility_error =
|
|
print_utility_error("uhd_images_downloader", "--help");
|
|
std::cout << "utility_error: " << utility_error << std::endl;
|
|
}
|