2020-09-05 14:01:32 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
|
|
|
|
|
namespace Compression.BSA
|
|
|
|
|
{
|
|
|
|
|
public class MemoryStreamFactory : IStreamFactory
|
|
|
|
|
{
|
|
|
|
|
private readonly MemoryStream _data;
|
|
|
|
|
|
2020-09-08 22:15:33 +00:00
|
|
|
|
public MemoryStreamFactory(MemoryStream data, IPath path)
|
2020-09-05 14:01:32 +00:00
|
|
|
|
{
|
|
|
|
|
_data = data;
|
2020-09-08 22:15:33 +00:00
|
|
|
|
Name = path;
|
2020-09-05 14:01:32 +00:00
|
|
|
|
}
|
|
|
|
|
public async ValueTask<Stream> GetStream()
|
|
|
|
|
{
|
|
|
|
|
return new MemoryStream(_data.GetBuffer(), 0, (int)_data.Length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DateTime LastModifiedUtc => DateTime.UtcNow;
|
2020-09-08 22:15:33 +00:00
|
|
|
|
public IPath Name { get; }
|
2020-09-05 14:01:32 +00:00
|
|
|
|
}
|
2020-09-08 02:22:23 +00:00
|
|
|
|
|
|
|
|
|
public class MemoryBufferFactory : IStreamFactory
|
|
|
|
|
{
|
|
|
|
|
private readonly byte[] _data;
|
|
|
|
|
private int _size;
|
|
|
|
|
|
2020-09-08 22:15:33 +00:00
|
|
|
|
public MemoryBufferFactory(byte[] data, int size, IPath path)
|
2020-09-08 02:22:23 +00:00
|
|
|
|
{
|
|
|
|
|
_data = data;
|
|
|
|
|
_size = size;
|
2020-09-08 22:15:33 +00:00
|
|
|
|
Name = path;
|
2020-09-08 02:22:23 +00:00
|
|
|
|
}
|
|
|
|
|
public async ValueTask<Stream> GetStream()
|
|
|
|
|
{
|
|
|
|
|
return new MemoryStream(_data, 0, _size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DateTime LastModifiedUtc => DateTime.UtcNow;
|
2020-09-08 22:15:33 +00:00
|
|
|
|
public IPath Name { get; }
|
2020-09-08 02:22:23 +00:00
|
|
|
|
}
|
2020-09-05 14:01:32 +00:00
|
|
|
|
}
|