// Copyright Epic Games, Inc. All Rights Reserved. #include "zencore/testutils.h" #include #include "zencore/string.h" #include namespace zen { static std::atomic Sequence{0}; std::filesystem::path CreateTemporaryDirectory() { std::error_code Ec; std::filesystem::path DirPath = std::filesystem::temp_directory_path() / GetSessionIdString() / IntNum(++Sequence).c_str(); std::filesystem::remove_all(DirPath, Ec); std::filesystem::create_directories(DirPath); return DirPath; } ScopedTemporaryDirectory::ScopedTemporaryDirectory() : m_RootPath(CreateTemporaryDirectory()) { } ScopedTemporaryDirectory::ScopedTemporaryDirectory(std::filesystem::path Directory) : m_RootPath(Directory) { std::error_code Ec; std::filesystem::remove_all(Directory, Ec); std::filesystem::create_directories(Directory); } ScopedTemporaryDirectory::~ScopedTemporaryDirectory() { std::error_code Ec; std::filesystem::remove_all(m_RootPath, Ec); } } // namespace zen