wabbajack/Wabbajack.Paths.IO/TemporaryPath.cs
2021-10-23 10:51:17 -06:00

34 lines
597 B
C#

using System;
using System.Threading.Tasks;
namespace Wabbajack.Paths.IO;
public struct TemporaryPath : IDisposable, IAsyncDisposable
{
public readonly AbsolutePath Path { get; init; }
public TemporaryPath(AbsolutePath path)
{
Path = path;
}
public void Dispose()
{
Path.Delete();
}
public override string ToString()
{
return Path.ToString();
}
public static implicit operator AbsolutePath(TemporaryPath tp)
{
return tp.Path;
}
public async ValueTask DisposeAsync()
{
Path.Delete();
}
}