diff options
| author | Wladimir J. van der Laan <[email protected]> | 2016-03-14 11:18:02 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2016-03-14 11:26:52 +0100 |
| commit | 56d2c4e0fee3372535a4b4436cebca94f2eda0ad (patch) | |
| tree | 14cf59303763e6e1f53c350182247c8f7f4653da /src/test/testutil.cpp | |
| parent | Merge #7668: Fix history deletion bug after font size change (diff) | |
| parent | Move GetTempPath() to testutil. (diff) | |
| download | discoin-56d2c4e0fee3372535a4b4436cebca94f2eda0ad.tar.xz discoin-56d2c4e0fee3372535a4b4436cebca94f2eda0ad.zip | |
Merge #7667: Move GetTempPath() to testutil
2fdaa25 Move GetTempPath() to testutil. (Mustafa)
393b22e Add a source file for unit test utils. (Mustafa)
Diffstat (limited to 'src/test/testutil.cpp')
| -rw-r--r-- | src/test/testutil.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/testutil.cpp b/src/test/testutil.cpp new file mode 100644 index 000000000..304cffb79 --- /dev/null +++ b/src/test/testutil.cpp @@ -0,0 +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 <shlobj.h> +#endif + +#include <boost/filesystem.hpp> + +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 +} |