mirror of
https://github.com/chylex/Brotli-Builder.git
synced 2025-08-16 21:31:47 +02:00
BrotliBuilder
BrotliCalc
BrotliImpl
BrotliLib
Brotli
Components
Dictionary
Default
Format
Index
Source
IDictionarySource.cs
MemorySource.cs
OpenFileSource.cs
StreamSource.cs
Transform
BrotliDictionary.cs
Encode
Output
Parameters
Streaming
Utils
BrotliFileStructure.cs
BrotliGlobalState.cs
Collections
Exceptions
Markers
Numbers
Serialization
BrotliLib.csproj
LICENSE-BROTLI.txt
UnitTests
.gitignore
BrotliBuilder.sln
LICENSE
README.md
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;
|
|
}
|
|
}
|
|
}
|