mirror of
https://github.com/MobileTooling/DotnetPackaging.git
synced 2026-07-27 12:50:21 -07:00
31 lines
708 B
C#
31 lines
708 B
C#
using System.IO.Abstractions;
|
|
using CSharpFunctionalExtensions;
|
|
using Zafiro.DivineBytes;
|
|
|
|
namespace RemakeAppx.Helpers;
|
|
|
|
internal class IOFile : INamedByteSource
|
|
{
|
|
private readonly IFileInfo fileInfo;
|
|
|
|
public IOFile(IFileInfo info)
|
|
{
|
|
fileInfo = info;
|
|
Source = ByteSource.FromStreamFactory(info.OpenRead, async () => info.Length);
|
|
}
|
|
|
|
public IByteSource Source { get; }
|
|
|
|
public string Name => fileInfo.Name;
|
|
public IDisposable Subscribe(IObserver<byte[]> observer)
|
|
{
|
|
return Source.Subscribe(observer);
|
|
}
|
|
|
|
public IObservable<byte[]> Bytes => Source.Bytes;
|
|
|
|
public Task<Maybe<long>> GetLength()
|
|
{
|
|
return Source.GetLength();
|
|
}
|
|
} |