@@ -66,7 +66,7 @@ during decompression.
66
66
int [ ] [ ] perm = new int [ BZip2Constants . GroupCount ] [ ] ;
67
67
int [ ] minLens = new int [ BZip2Constants . GroupCount ] ;
68
68
69
- Stream baseStream ;
69
+ readonly Stream baseStream ;
70
70
bool streamEnd ;
71
71
72
72
int currentChar = - 1 ;
@@ -91,14 +91,18 @@ during decompression.
91
91
/// <param name="stream">Data source</param>
92
92
public BZip2InputStream ( Stream stream )
93
93
{
94
+ if ( stream == null )
95
+ throw new ArgumentNullException ( nameof ( stream ) ) ;
94
96
// init arrays
95
97
for ( int i = 0 ; i < BZip2Constants . GroupCount ; ++ i ) {
96
98
limit [ i ] = new int [ BZip2Constants . MaximumAlphaSize ] ;
97
99
baseArray [ i ] = new int [ BZip2Constants . MaximumAlphaSize ] ;
98
100
perm [ i ] = new int [ BZip2Constants . MaximumAlphaSize ] ;
99
101
}
100
102
101
- BsSetStream ( stream ) ;
103
+ baseStream = stream ;
104
+ bsLive = 0 ;
105
+ bsBuff = 0 ;
102
106
Initialize ( ) ;
103
107
InitBlock ( ) ;
104
108
SetupBlock ( ) ;
@@ -149,10 +153,10 @@ public override long Length {
149
153
}
150
154
151
155
/// <summary>
152
- /// Gets or sets the streams position.
153
- /// Setting the position is not supported and will throw a NotSupportException
156
+ /// Gets the current position of the stream .
157
+ /// Setting the position is not supported and will throw a NotSupportException.
154
158
/// </summary>
155
- /// <exception cref="NotSupportedException">Any attempt to set the position</exception>
159
+ /// <exception cref="NotSupportedException">Any attempt to set the position. </exception>
156
160
public override long Position {
157
161
get {
158
162
return baseStream . Position ;
@@ -167,9 +171,7 @@ public override long Position {
167
171
/// </summary>
168
172
public override void Flush ( )
169
173
{
170
- if ( baseStream != null ) {
171
- baseStream . Flush ( ) ;
172
- }
174
+ baseStream . Flush ( ) ;
173
175
}
174
176
175
177
/// <summary>
@@ -250,7 +252,7 @@ public override int Read(byte[] buffer, int offset, int count)
250
252
/// </summary>
251
253
protected override void Dispose ( bool disposing )
252
254
{
253
- if ( disposing && IsStreamOwner && ( baseStream != null ) ) {
255
+ if ( disposing && IsStreamOwner ) {
254
256
baseStream . Dispose ( ) ;
255
257
}
256
258
}
@@ -371,13 +373,6 @@ void Complete()
371
373
streamEnd = true ;
372
374
}
373
375
374
- void BsSetStream ( Stream stream )
375
- {
376
- baseStream = stream ;
377
- bsLive = 0 ;
378
- bsBuff = 0 ;
379
- }
380
-
381
376
void FillBuffer ( )
382
377
{
383
378
int thech = 0 ;
0 commit comments