1
0
mirror of https://github.com/chylex/Brotli-Builder.git synced 2024-11-25 07:42:56 +01: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;
}
}
}