summaryrefslogtreecommitdiffstats
path: root/host/lib/utils/paths.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2012-05-15 11:11:35 -0700
committerJosh Blum <josh@joshknows.com>2012-05-16 10:59:09 -0700
commit8d5dc71d64e91d0ed85730e3c2a5b9ea494dc25c (patch)
treec7b0a599c0e26f0f00adbceef9f4a94d8d318a21 /host/lib/utils/paths.cpp
parent78bf395b2d9ab0ae3ec2b9c7cd583f30a4780d95 (diff)
downloaduhd-8d5dc71d64e91d0ed85730e3c2a5b9ea494dc25c.tar.gz
uhd-8d5dc71d64e91d0ed85730e3c2a5b9ea494dc25c.tar.bz2
uhd-8d5dc71d64e91d0ed85730e3c2a5b9ea494dc25c.zip
uhd: used shared get_tmp_path for logging as well
Moved some of the log.cpp tmp paths smarts into paths as well
Diffstat (limited to 'host/lib/utils/paths.cpp')
-rw-r--r--host/lib/utils/paths.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp
index 4fc877d5d..43094521a 100644
--- a/host/lib/utils/paths.cpp
+++ b/host/lib/utils/paths.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010-2011 Ettus Research LLC
+// Copyright 2010-2012 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -26,6 +26,10 @@
#include <vector>
#include <cstdlib> //getenv
#include <cstdio> //P_tmpdir
+#ifdef BOOST_MSVC
+#define USE_GET_TEMP_PATH
+#include <windows.h> //GetTempPath
+#endif
namespace fs = boost::filesystem;
@@ -87,13 +91,35 @@ std::vector<fs::path> get_module_paths(void){
* Implement the functions in paths.hpp
**********************************************************************/
std::string uhd::get_tmp_path(void){
- const char *tmp_path = std::getenv("TMP");
+ const char *tmp_path = NULL;
+
+ //try the official uhd temp path environment variable
+ tmp_path = std::getenv("UHD_TEMP_PATH");
+ if (tmp_path != NULL) return tmp_path;
+
+ //try the windows function if available
+ #ifdef USE_GET_TEMP_PATH
+ char lpBuffer[2048];
+ if (GetTempPath(sizeof(lpBuffer), lpBuffer)) return lpBuffer;
+ #endif
+
+ //try windows environment variables
+ tmp_path = std::getenv("TMP");
if (tmp_path != NULL) return tmp_path;
+ tmp_path = std::getenv("TEMP");
+ if (tmp_path != NULL) return tmp_path;
+
+ //try the stdio define if available
#ifdef P_tmpdir
if (P_tmpdir != NULL) return P_tmpdir;
#endif
+ //try unix environment variables
+ tmp_path = std::getenv("TMPDIR");
+ if (tmp_path != NULL) return tmp_path;
+
+ //give up and use the unix default
return "/tmp";
}