summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/vmcircbuf_prefs.cc
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2019-08-07 21:45:12 +0200
committerMarcus Müller <marcus@hostalia.de>2019-08-09 23:04:28 +0200
commitf7bbf2c1d8d780294f3e016aff239ca35eb6516e (patch)
treee09ab6112e02b2215b2d59ac24d3d6ea2edac745 /gnuradio-runtime/lib/vmcircbuf_prefs.cc
parent78431dc6941e3acc67c858277dfe4a0ed583643c (diff)
Tree: clang-format without the include sorting
Diffstat (limited to 'gnuradio-runtime/lib/vmcircbuf_prefs.cc')
-rw-r--r--gnuradio-runtime/lib/vmcircbuf_prefs.cc88
1 files changed, 42 insertions, 46 deletions
diff --git a/gnuradio-runtime/lib/vmcircbuf_prefs.cc b/gnuradio-runtime/lib/vmcircbuf_prefs.cc
index 4cb09f69f8..80c36f189f 100644
--- a/gnuradio-runtime/lib/vmcircbuf_prefs.cc
+++ b/gnuradio-runtime/lib/vmcircbuf_prefs.cc
@@ -41,77 +41,73 @@ namespace fs = boost::filesystem;
namespace gr {
- /*
- * The simplest thing that could possibly work:
- * the key is the filename; the value is the file contents.
- */
-
- static std::string
- pathname(const char *key)
- {
+/*
+ * The simplest thing that could possibly work:
+ * the key is the filename; the value is the file contents.
+ */
+
+static std::string pathname(const char* key)
+{
static fs::path path;
- path = fs::path(gr::appdata_path()) / ".gnuradio" / "prefs" / key;
+ path = fs::path(gr::appdata_path()) / ".gnuradio" / "prefs" / key;
return path.string();
- }
+}
- static void
- ensure_dir_path()
- {
+static void ensure_dir_path()
+{
fs::path path = fs::path(gr::appdata_path()) / ".gnuradio";
- if(!fs::is_directory(path))
- fs::create_directory(path);
+ if (!fs::is_directory(path))
+ fs::create_directory(path);
path = path / "prefs";
- if(!fs::is_directory(path))
- fs::create_directory(path);
- }
+ if (!fs::is_directory(path))
+ fs::create_directory(path);
+}
- int
- vmcircbuf_prefs::get(const char *key, char *value, int value_size)
- {
+int vmcircbuf_prefs::get(const char* key, char* value, int value_size)
+{
gr::thread::scoped_lock guard(s_vm_mutex);
- FILE *fp = fopen(pathname (key).c_str(), "r");
- if(fp == 0) {
- perror(pathname (key).c_str());
- return 0;
+ FILE* fp = fopen(pathname(key).c_str(), "r");
+ if (fp == 0) {
+ perror(pathname(key).c_str());
+ return 0;
}
const size_t ret = fread(value, 1, value_size - 1, fp);
value[ret] = '\0';
- if(ret == 0 && !feof(fp)) {
- if(ferror(fp) != 0) {
- perror(pathname (key).c_str());
- fclose(fp);
- return -1;
- }
+ if (ret == 0 && !feof(fp)) {
+ if (ferror(fp) != 0) {
+ perror(pathname(key).c_str());
+ fclose(fp);
+ return -1;
+ }
}
fclose(fp);
return ret;
- }
+}
- void
- vmcircbuf_prefs::set(const char *key, const char *value)
- {
+void vmcircbuf_prefs::set(const char* key, const char* value)
+{
gr::thread::scoped_lock guard(s_vm_mutex);
ensure_dir_path();
- FILE *fp = fopen(pathname(key).c_str(), "w");
- if(fp == 0) {
- perror(pathname (key).c_str());
- return;
+ FILE* fp = fopen(pathname(key).c_str(), "w");
+ if (fp == 0) {
+ 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).c_str());
- fclose(fp);
- return;
- }
+ if (ret == 0) {
+ if (ferror(fp) != 0) {
+ perror(pathname(key).c_str());
+ fclose(fp);
+ return;
+ }
}
fclose(fp);
- };
+};
} /* namespace gr */