2021-09-27 12:42:46 +00:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Wabbajack.DTOs.Streams;
|
|
|
|
using Wabbajack.Paths;
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
namespace Wabbajack.Common;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public class MemoryStreamFactory : IStreamFactory
|
|
|
|
{
|
|
|
|
private readonly MemoryStream _data;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public MemoryStreamFactory(MemoryStream data, IPath path, DateTime lastModified)
|
|
|
|
{
|
|
|
|
_data = data;
|
|
|
|
Name = path;
|
|
|
|
LastModifiedUtc = lastModified;
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public ValueTask<Stream> GetStream()
|
|
|
|
{
|
|
|
|
return new ValueTask<Stream>(new MemoryStream(_data.GetBuffer(), 0, (int) _data.Length));
|
2021-09-27 12:42:46 +00:00
|
|
|
}
|
2021-10-23 16:51:17 +00:00
|
|
|
|
|
|
|
public DateTime LastModifiedUtc { get; }
|
|
|
|
public IPath Name { get; }
|
2021-09-27 12:42:46 +00:00
|
|
|
}
|