2021-09-27 12:42:46 +00:00
|
|
|
using System;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
namespace Wabbajack.Paths.IO;
|
|
|
|
|
|
|
|
public struct TemporaryPath : IDisposable, IAsyncDisposable
|
2021-09-27 12:42:46 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
public readonly AbsolutePath Path { get; init; }
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public TemporaryPath(AbsolutePath path)
|
|
|
|
{
|
|
|
|
Path = path;
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
Path.Delete();
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return Path.ToString();
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public static implicit operator AbsolutePath(TemporaryPath tp)
|
|
|
|
{
|
|
|
|
return tp.Path;
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public async ValueTask DisposeAsync()
|
|
|
|
{
|
|
|
|
Path.Delete();
|
2021-09-27 12:42:46 +00:00
|
|
|
}
|
|
|
|
}
|