2020-10-10 03:02:58 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
using System.Threading;
|
2020-10-10 03:02:58 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
using Wabbajack.DTOs.Streams;
|
|
|
|
|
using Wabbajack.Paths;
|
|
|
|
|
using Wabbajack.Paths.IO;
|
2020-10-10 03:02:58 +00:00
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
|
namespace Wabbajack.FileExtractor.ExtractedFiles;
|
2020-10-10 03:02:58 +00:00
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
|
public class ExtractedMemoryFile : IExtractedFile
|
|
|
|
|
{
|
|
|
|
|
private readonly IStreamFactory _factory;
|
2020-10-10 03:02:58 +00:00
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
|
public ExtractedMemoryFile(IStreamFactory factory)
|
|
|
|
|
{
|
|
|
|
|
_factory = factory;
|
|
|
|
|
}
|
2020-10-10 03:02:58 +00:00
|
|
|
|
|
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
|
public ValueTask<Stream> GetStream()
|
|
|
|
|
{
|
|
|
|
|
return _factory.GetStream();
|
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
|
public DateTime LastModifiedUtc => _factory.LastModifiedUtc;
|
|
|
|
|
public IPath Name => _factory.Name;
|
2020-10-10 03:02:58 +00:00
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
|
public async ValueTask Move(AbsolutePath newPath, CancellationToken token)
|
|
|
|
|
{
|
|
|
|
|
await using var stream = await _factory.GetStream();
|
|
|
|
|
await newPath.WriteAllAsync(stream, token);
|
2020-10-10 03:02:58 +00:00
|
|
|
|
}
|
2021-10-23 16:51:17 +00:00
|
|
|
|
|
|
|
|
|
public bool CanMove { get; set; } = true;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
}
|