| 11 | #include <boost/filesystem.hpp> |
| 12 | |
| 13 | boost::filesystem::path GetTempPath() { |
| 14 | #if BOOST_FILESYSTEM_VERSION == 3 |
| 15 | return boost::filesystem::temp_directory_path(); |
| 16 | #else |
| 17 | // TODO: remove when we don't support filesystem v2 anymore |
| 18 | boost::filesystem::path path; |
| 19 | #ifdef WIN32 |
| 20 | char pszPath[MAX_PATH] = ""; |
| 21 | |
| 22 | if (GetTempPathA(MAX_PATH, pszPath)) |
| 23 | path = boost::filesystem::path(pszPath); |
| 24 | #else |
| 25 | path = boost::filesystem::path("/tmp"); |
| 26 | #endif |
| 27 | if (path.empty() || !boost::filesystem::is_directory(path)) { |
| 28 | LogPrintf("GetTempPath(): failed to find temp path\n"); |
| 29 | return boost::filesystem::path(""); |
| 30 | } |
| 31 | return path; |
| 32 | #endif |
| 33 | } |