2020-03-04 05:23:08 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using File = Alphaleonis.Win32.Filesystem.File;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Common
|
|
|
|
|
{
|
|
|
|
|
public class TempStream : FileStream
|
|
|
|
|
{
|
|
|
|
|
private TempFile _file;
|
|
|
|
|
|
|
|
|
|
public TempStream(TempFile file) : base(file.File.FullName, FileMode.Create, FileAccess.ReadWrite)
|
|
|
|
|
{
|
|
|
|
|
_file = file;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TempStream() : this(new TempFile())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(disposing);
|
2020-05-28 02:43:57 +00:00
|
|
|
|
_file.DisposeAsync().AsTask().Wait();
|
2020-03-04 05:23:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override async ValueTask DisposeAsync()
|
|
|
|
|
{
|
|
|
|
|
await base.DisposeAsync();
|
2020-05-28 02:43:57 +00:00
|
|
|
|
await _file.DisposeAsync();
|
2020-03-04 05:23:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|