From 2fdaa255295402d24bb16a72b07cc72c9a5df8e4 Mon Sep 17 00:00:00 2001 From: Mustafa Date: Fri, 11 Mar 2016 15:04:05 +0000 Subject: Move GetTempPath() to testutil. --- src/test/testutil.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/test/testutil.cpp') diff --git a/src/test/testutil.cpp b/src/test/testutil.cpp index de01228f0..304cffb79 100644 --- a/src/test/testutil.cpp +++ b/src/test/testutil.cpp @@ -1,3 +1,33 @@ // Copyright (c) 2009-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "testutil.h" + +#ifdef WIN32 +#include +#endif + +#include + +boost::filesystem::path GetTempPath() { +#if BOOST_FILESYSTEM_VERSION == 3 + return boost::filesystem::temp_directory_path(); +#else + // TODO: remove when we don't support filesystem v2 anymore + boost::filesystem::path path; +#ifdef WIN32 + char pszPath[MAX_PATH] = ""; + + if (GetTempPathA(MAX_PATH, pszPath)) + path = boost::filesystem::path(pszPath); +#else + path = boost::filesystem::path("/tmp"); +#endif + if (path.empty() || !boost::filesystem::is_directory(path)) { + LogPrintf("GetTempPath(): failed to find temp path\n"); + return boost::filesystem::path(""); + } + return path; +#endif +} -- cgit v1.2.3