summaryrefslogtreecommitdiff
path: root/gnuradio-runtime
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime')
-rw-r--r--gnuradio-runtime/apps/gnuradio-config-info.cc10
-rw-r--r--gnuradio-runtime/include/gnuradio/sys_paths.h3
-rw-r--r--gnuradio-runtime/lib/prefs.cc13
-rw-r--r--gnuradio-runtime/lib/sys_paths.cc9
-rw-r--r--gnuradio-runtime/lib/vmcircbuf_prefs.cc19
5 files changed, 37 insertions, 17 deletions
diff --git a/gnuradio-runtime/apps/gnuradio-config-info.cc b/gnuradio-runtime/apps/gnuradio-config-info.cc
index c91b080039..813dda138c 100644
--- a/gnuradio-runtime/apps/gnuradio-config-info.cc
+++ b/gnuradio-runtime/apps/gnuradio-config-info.cc
@@ -25,6 +25,8 @@
#endif
#include <gnuradio/constants.h>
+#include <gnuradio/sys_paths.h>
+#include <gnuradio/prefs.h>
#include <boost/program_options.hpp>
#include <boost/format.hpp>
#include <iostream>
@@ -43,6 +45,8 @@ main(int argc, char **argv)
("prefix", "print GNU Radio installation prefix")
("sysconfdir", "print GNU Radio system configuration directory")
("prefsdir", "print GNU Radio preferences directory")
+ ("userprefsdir", "print GNU Radio user preferences directory")
+ ("prefs", "print GNU Radio preferences")
("builddate", "print GNU Radio build date (RFC2822 format)")
("enabled-components", "print GNU Radio build time enabled components")
("cc", "print GNU Radio C compiler version")
@@ -75,6 +79,12 @@ main(int argc, char **argv)
if(vm.count("prefsdir"))
std::cout << gr::prefsdir() << std::endl;
+ if(vm.count("userprefsdir"))
+ std::cout << gr::userconf_path() << std::endl;
+
+ if(vm.count("prefs"))
+ std::cout << gr::prefs::singleton()->to_string() << std::endl;
+
if(vm.count("builddate"))
std::cout << gr::build_date() << std::endl;
diff --git a/gnuradio-runtime/include/gnuradio/sys_paths.h b/gnuradio-runtime/include/gnuradio/sys_paths.h
index 1bd2e0deb7..efea07b599 100644
--- a/gnuradio-runtime/include/gnuradio/sys_paths.h
+++ b/gnuradio-runtime/include/gnuradio/sys_paths.h
@@ -32,6 +32,9 @@ namespace gr {
//! directory to store application data
GR_RUNTIME_API const char *appdata_path();
+ //! directory to store user configuration
+ GR_RUNTIME_API const char *userconf_path();
+
} /* namespace gr */
#endif /* GR_SYS_PATHS_H */
diff --git a/gnuradio-runtime/lib/prefs.cc b/gnuradio-runtime/lib/prefs.cc
index b303ffdaf9..7fd38ef6d7 100644
--- a/gnuradio-runtime/lib/prefs.cc
+++ b/gnuradio-runtime/lib/prefs.cc
@@ -77,10 +77,9 @@ namespace gr {
// Find if there is a ~/.gnuradio/config.conf file and add this to
// the end of the file list to override any preferences in the
// installed path config files.
- fs::path homedir = fs::path(gr::appdata_path());
- homedir = homedir/".gnuradio/config.conf";
- if(fs::exists(homedir)) {
- fnames.push_back(homedir.string());
+ fs::path userconf = fs::path(gr::userconf_path()) / "config.conf";
+ if(fs::exists(userconf)) {
+ fnames.push_back(userconf.string());
}
return fnames;
@@ -222,10 +221,8 @@ namespace gr {
prefs::save()
{
std::string conf = to_string();
-
- fs::path homedir = fs::path(gr::appdata_path());
- homedir = homedir/".gnuradio/config.conf";
- fs::ofstream fout(homedir);
+ fs::path userconf = fs::path(gr::userconf_path()) / "config.conf";
+ fs::ofstream fout(userconf);
fout << conf;
fout.close();
}
diff --git a/gnuradio-runtime/lib/sys_paths.cc b/gnuradio-runtime/lib/sys_paths.cc
index 64853c68b2..3bf6697bac 100644
--- a/gnuradio-runtime/lib/sys_paths.cc
+++ b/gnuradio-runtime/lib/sys_paths.cc
@@ -23,6 +23,8 @@
#include <cstdlib> //getenv
#include <cstdio> //P_tmpdir (maybe)
+#include <boost/filesystem/path.hpp>
+
namespace gr {
const char *tmp_path()
@@ -62,4 +64,11 @@ namespace gr {
return tmp_path();
}
+ const char *userconf_path()
+ {
+ boost::filesystem::path p(appdata_path());
+ p = p / ".gnuradio";
+ return p.c_str();
+ }
+
} /* namespace gr */
diff --git a/gnuradio-runtime/lib/vmcircbuf_prefs.cc b/gnuradio-runtime/lib/vmcircbuf_prefs.cc
index a786b8a881..4cb09f69f8 100644
--- a/gnuradio-runtime/lib/vmcircbuf_prefs.cc
+++ b/gnuradio-runtime/lib/vmcircbuf_prefs.cc
@@ -45,12 +45,13 @@ namespace gr {
* The simplest thing that could possibly work:
* the key is the filename; the value is the file contents.
*/
- static const char *
+
+ static std::string
pathname(const char *key)
{
static fs::path path;
- path = fs::path(gr::appdata_path()) / ".gnuradio" / "prefs" / key;
- return path.string().c_str();
+ path = fs::path(gr::appdata_path()) / ".gnuradio" / "prefs" / key;
+ return path.string();
}
static void
@@ -70,9 +71,9 @@ namespace gr {
{
gr::thread::scoped_lock guard(s_vm_mutex);
- FILE *fp = fopen(pathname (key), "r");
+ FILE *fp = fopen(pathname (key).c_str(), "r");
if(fp == 0) {
- perror(pathname (key));
+ perror(pathname (key).c_str());
return 0;
}
@@ -80,7 +81,7 @@ namespace gr {
value[ret] = '\0';
if(ret == 0 && !feof(fp)) {
if(ferror(fp) != 0) {
- perror(pathname (key));
+ perror(pathname (key).c_str());
fclose(fp);
return -1;
}
@@ -96,16 +97,16 @@ namespace gr {
ensure_dir_path();
- FILE *fp = fopen(pathname(key), "w");
+ FILE *fp = fopen(pathname(key).c_str(), "w");
if(fp == 0) {
- perror(pathname (key));
+ perror(pathname (key).c_str());
return;
}
size_t ret = fwrite(value, 1, strlen(value), fp);
if(ret == 0) {
if(ferror(fp) != 0) {
- perror(pathname (key));
+ perror(pathname (key).c_str());
fclose(fp);
return;
}