All checks were successful
default / dotnet default workflow (8.0) (push) Successful in 47s
33 lines
No EOL
749 B
C#
33 lines
No EOL
749 B
C#
// Copyright (c) The Geekeey Authors
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
using System.Reflection;
|
|
|
|
namespace Geekeey.Extensions.Process.Tests;
|
|
|
|
internal sealed class TestTempFile(string path) : IDisposable
|
|
{
|
|
public static TestTempFile Create()
|
|
{
|
|
var location = Assembly.GetExecutingAssembly().Location;
|
|
var pwd = System.IO.Path.GetDirectoryName(location) ?? Directory.GetCurrentDirectory();
|
|
var dirPath = System.IO.Path.Combine(pwd, "Temp");
|
|
|
|
Directory.CreateDirectory(dirPath);
|
|
|
|
var filePath = System.IO.Path.Combine(dirPath, Guid.NewGuid() + ".tmp");
|
|
|
|
return new TestTempFile(filePath);
|
|
}
|
|
|
|
public string Path { get; } = path;
|
|
|
|
public void Dispose()
|
|
{
|
|
try
|
|
{
|
|
File.Delete(Path);
|
|
}
|
|
catch (FileNotFoundException) { }
|
|
}
|
|
} |