wabbajack/Wabbajack.Common/IStreamFactory.cs

42 lines
911 B
C#
Raw Normal View History

using System;
using System.IO;
using System.Threading.Tasks;
using Wabbajack.Common;
namespace Wabbajack.Common
{
public interface IStreamFactory
{
ValueTask<Stream> GetStream();
DateTime LastModifiedUtc { get; }
IPath Name { get; }
}
public class NativeFileStreamFactory : IStreamFactory
{
private AbsolutePath _file;
2020-09-08 22:15:33 +00:00
public NativeFileStreamFactory(AbsolutePath file, IPath path)
{
_file = file;
Name = path;
}
public NativeFileStreamFactory(AbsolutePath file)
{
_file = file;
2020-09-08 22:15:33 +00:00
Name = file;
}
public async ValueTask<Stream> GetStream()
{
return await _file.OpenRead();
}
public DateTime LastModifiedUtc => _file.LastModifiedUtc;
2020-09-08 22:15:33 +00:00
public IPath Name { get; }
}
}