summaryrefslogtreecommitdiffstats
path: root/host/lib/utils/paths.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/utils/paths.cpp')
-rw-r--r--host/lib/utils/paths.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp
index a3dd377e5..4fc877d5d 100644
--- a/host/lib/utils/paths.cpp
+++ b/host/lib/utils/paths.cpp
@@ -16,6 +16,7 @@
//
#include <uhd/config.hpp>
+#include <uhd/utils/paths.hpp>
#include <boost/tokenizer.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
@@ -23,6 +24,8 @@
#include <cstdlib>
#include <string>
#include <vector>
+#include <cstdlib> //getenv
+#include <cstdio> //P_tmpdir
namespace fs = boost::filesystem;
@@ -79,3 +82,27 @@ std::vector<fs::path> get_module_paths(void){
paths.push_back(get_uhd_pkg_data_path() / "modules");
return paths;
}
+
+/***********************************************************************
+ * Implement the functions in paths.hpp
+ **********************************************************************/
+std::string uhd::get_tmp_path(void){
+ const char *tmp_path = std::getenv("TMP");
+ if (tmp_path != NULL) return tmp_path;
+
+ #ifdef P_tmpdir
+ if (P_tmpdir != NULL) return P_tmpdir;
+ #endif
+
+ return "/tmp";
+}
+
+std::string uhd::get_app_path(void){
+ const char *appdata_path = std::getenv("APPDATA");
+ if (appdata_path != NULL) return appdata_path;
+
+ const char *home_path = std::getenv("HOME");
+ if (home_path != NULL) return home_path;
+
+ return uhd::get_tmp_path();
+}