mirror of
https://github.com/chylex/Brotli-Builder.git
synced 2024-12-22 16:42:46 +01:00
30 lines
713 B
C#
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;
|
|
}
|
|
}
|
|
}
|