From 921b34eafd6f2abacf29614b0b029b06c2cf5b97 Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Wed, 20 Jan 2016 12:30:41 -0800 Subject: [PATCH] Use boost::filesystem instead of beast::File --- .../core/diagnostic/UnitTestUtilities.h | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/beast/module/core/diagnostic/UnitTestUtilities.h b/beast/module/core/diagnostic/UnitTestUtilities.h index 12853d1d..d625a5a3 100644 --- a/beast/module/core/diagnostic/UnitTestUtilities.h +++ b/beast/module/core/diagnostic/UnitTestUtilities.h @@ -20,7 +20,8 @@ #ifndef BEAST_MODULE_CORE_DIAGNOSTIC_UNITTESTUTILITIES_H_INCLUDED #define BEAST_MODULE_CORE_DIAGNOSTIC_UNITTESTUTILITIES_H_INCLUDED -#include +#include +#include namespace beast { namespace UnitTestUtilities { @@ -28,26 +29,42 @@ namespace UnitTestUtilities { class TempDirectory { public: - explicit TempDirectory (std::string const& root) - : directory (File::createTempFile (root)) + TempDirectory () { + auto const tempDir = + boost::filesystem::temp_directory_path(); + + do + { + tempPath = + tempDir / boost::filesystem::unique_path(); + } while (boost::filesystem::exists(tempPath)); + + boost::filesystem::create_directory (tempPath); } ~TempDirectory() { - directory.deleteRecursively(); + boost::filesystem::remove_all (tempPath); } - String const& getFullPathName() const + /** Returns the native path for the temporary folder */ + std::string path() const { - return directory.getFullPathName(); + return tempPath.string(); + } + + /** Returns the native for the given file */ + std::string file (std::string const& name) const + { + return (tempPath / name).string(); } TempDirectory(const TempDirectory&) = delete; TempDirectory& operator=(const TempDirectory&) = delete; private: - File const directory; + boost::filesystem::path tempPath; }; } // UnitTestUtilities