// Copyright (c) The Geekeey Authors // SPDX-License-Identifier: EUPL-1.2 namespace Geekeey.Process.Tests; internal sealed class TestTempDirectory : IDisposable { private TestTempDirectory(string path) { Path = path; } public static TestTempDirectory Create() { var location = System.Reflection.Assembly.GetExecutingAssembly().Location; var pwd = System.IO.Path.GetDirectoryName(location) ?? Directory.GetCurrentDirectory(); var dirPath = System.IO.Path.Combine(pwd, "Temp", Guid.NewGuid().ToString()); Directory.CreateDirectory(dirPath); return new TestTempDirectory(dirPath); } public string Path { get; } public void Dispose() { try { Directory.Delete(Path, recursive: true); } catch (DirectoryNotFoundException) { } } }