1
0
mirror of https://github.com/chylex/Brotli-Builder.git synced 2024-10-17 12:42:47 +02:00
Brotli-Builder/BrotliLib/Brotli/Dictionary/Source/StreamSource.cs

30 lines
713 B
C#

using System.IO;
namespace BrotliLib.Brotli.Dictionary.Source{
/// <summary>
/// Reads dictionary words from a generic stream.
/// </summary>
public class StreamSource : IDictionarySource{
private readonly Stream stream;
public StreamSource(Stream stream){
this.stream = stream;
}
public void Dispose(){
stream.Dispose();
}
byte[] IDictionarySource.ReadBytes(int position, int count){
byte[] bytes = new byte[count];
lock(stream){
stream.Seek(position, SeekOrigin.Begin);
stream.Read(bytes, 0, count);
}
return bytes;
}
}
}