wabbajack/Wabbajack.FileExtractor/ExtractedFiles/ExtractedMemoryfile.cs

36 lines
864 B
C#
Raw Normal View History

using System;
using System.IO;
2021-09-27 12:42:46 +00:00
using System.Threading;
using System.Threading.Tasks;
2021-09-27 12:42:46 +00:00
using Wabbajack.DTOs.Streams;
using Wabbajack.Paths;
using Wabbajack.Paths.IO;
2021-10-23 16:51:17 +00:00
namespace Wabbajack.FileExtractor.ExtractedFiles;
2021-10-23 16:51:17 +00:00
public class ExtractedMemoryFile : IExtractedFile
{
private readonly IStreamFactory _factory;
2021-10-23 16:51:17 +00:00
public ExtractedMemoryFile(IStreamFactory factory)
{
_factory = factory;
}
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;
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);
}
2021-10-23 16:51:17 +00:00
public bool CanMove { get; set; } = true;
2021-09-27 12:42:46 +00:00
}