@@ -94,7 +94,8 @@ public BZip2OutputStream(Stream stream, int blockSize)
9494 /// Get/set flag indicating ownership of underlying stream.
9595 /// When the flag is true <see cref="Close"></see> will close the underlying stream also.
9696 /// </summary>
97- public bool IsStreamOwner {
97+ public bool IsStreamOwner
98+ {
9899 get { return isStreamOwner ; }
99100 set { isStreamOwner = value ; }
100101 }
@@ -104,47 +105,58 @@ public bool IsStreamOwner {
104105 /// <summary>
105106 /// Gets a value indicating whether the current stream supports reading
106107 /// </summary>
107- public override bool CanRead {
108- get {
108+ public override bool CanRead
109+ {
110+ get
111+ {
109112 return false ;
110113 }
111114 }
112115
113116 /// <summary>
114117 /// Gets a value indicating whether the current stream supports seeking
115118 /// </summary>
116- public override bool CanSeek {
117- get {
119+ public override bool CanSeek
120+ {
121+ get
122+ {
118123 return false ;
119124 }
120125 }
121126
122127 /// <summary>
123128 /// Gets a value indicating whether the current stream supports writing
124129 /// </summary>
125- public override bool CanWrite {
126- get {
130+ public override bool CanWrite
131+ {
132+ get
133+ {
127134 return baseStream . CanWrite ;
128135 }
129136 }
130137
131138 /// <summary>
132139 /// Gets the length in bytes of the stream
133140 /// </summary>
134- public override long Length {
135- get {
141+ public override long Length
142+ {
143+ get
144+ {
136145 return baseStream . Length ;
137146 }
138147 }
139148
140149 /// <summary>
141150 /// Gets or sets the current position of this stream.
142151 /// </summary>
143- public override long Position {
144- get {
152+ public override long Position
153+ {
154+ get
155+ {
145156 return baseStream . Position ;
146157 }
147- set {
158+ set
159+ {
148160 throw new NotSupportedException ( "BZip2OutputStream position cannot be set" ) ;
149161 }
150162 }
@@ -282,37 +294,37 @@ void WriteRun()
282294 }
283295
284296 switch ( runLength ) {
285- case 1 :
286- last ++ ;
287- block [ last + 1 ] = ( byte ) currentChar ;
288- break ;
289- case 2 :
290- last ++ ;
291- block [ last + 1 ] = ( byte ) currentChar ;
292- last ++ ;
293- block [ last + 1 ] = ( byte ) currentChar ;
294- break ;
295- case 3 :
296- last ++ ;
297- block [ last + 1 ] = ( byte ) currentChar ;
298- last ++ ;
299- block [ last + 1 ] = ( byte ) currentChar ;
300- last ++ ;
301- block [ last + 1 ] = ( byte ) currentChar ;
302- break ;
303- default :
304- inUse [ runLength - 4 ] = true ;
305- last ++ ;
306- block [ last + 1 ] = ( byte ) currentChar ;
307- last ++ ;
308- block [ last + 1 ] = ( byte ) currentChar ;
309- last ++ ;
310- block [ last + 1 ] = ( byte ) currentChar ;
311- last ++ ;
312- block [ last + 1 ] = ( byte ) currentChar ;
313- last ++ ;
314- block [ last + 1 ] = ( byte ) ( runLength - 4 ) ;
315- break ;
297+ case 1 :
298+ last ++ ;
299+ block [ last + 1 ] = ( byte ) currentChar ;
300+ break ;
301+ case 2 :
302+ last ++ ;
303+ block [ last + 1 ] = ( byte ) currentChar ;
304+ last ++ ;
305+ block [ last + 1 ] = ( byte ) currentChar ;
306+ break ;
307+ case 3 :
308+ last ++ ;
309+ block [ last + 1 ] = ( byte ) currentChar ;
310+ last ++ ;
311+ block [ last + 1 ] = ( byte ) currentChar ;
312+ last ++ ;
313+ block [ last + 1 ] = ( byte ) currentChar ;
314+ break ;
315+ default :
316+ inUse [ runLength - 4 ] = true ;
317+ last ++ ;
318+ block [ last + 1 ] = ( byte ) currentChar ;
319+ last ++ ;
320+ block [ last + 1 ] = ( byte ) currentChar ;
321+ last ++ ;
322+ block [ last + 1 ] = ( byte ) currentChar ;
323+ last ++ ;
324+ block [ last + 1 ] = ( byte ) currentChar ;
325+ last ++ ;
326+ block [ last + 1 ] = ( byte ) ( runLength - 4 ) ;
327+ break ;
316328 }
317329 } else {
318330 EndBlock ( ) ;
@@ -324,7 +336,8 @@ void WriteRun()
324336 /// <summary>
325337 /// Get the number of bytes written to the output.
326338 /// </summary>
327- public int BytesWritten {
339+ public int BytesWritten
340+ {
328341 get { return bytesOut ; }
329342 }
330343
@@ -335,25 +348,28 @@ public int BytesWritten {
335348 override protected void Dispose ( bool disposing )
336349 {
337350 try {
338- base . Dispose ( disposing ) ;
339- if ( ! disposed_ ) {
340- disposed_ = true ;
351+ try {
352+ base . Dispose ( disposing ) ;
353+ if ( ! disposed_ ) {
354+ disposed_ = true ;
341355
342- if ( runLength > 0 ) {
343- WriteRun ( ) ;
344- }
356+ if ( runLength > 0 ) {
357+ WriteRun ( ) ;
358+ }
345359
346- currentChar = - 1 ;
347- EndBlock ( ) ;
348- EndCompression ( ) ;
349- Flush ( ) ;
350- }
351- } finally {
352- if ( disposing ) {
353- if ( IsStreamOwner ) {
354- baseStream . Close ( ) ;
360+ currentChar = - 1 ;
361+ EndBlock ( ) ;
362+ EndCompression ( ) ;
363+ Flush ( ) ;
364+ }
365+ } finally {
366+ if ( disposing ) {
367+ if ( IsStreamOwner ) {
368+ baseStream . Close ( ) ;
369+ }
355370 }
356371 }
372+ } catch {
357373 }
358374 }
359375
@@ -1495,16 +1511,16 @@ void GenerateMTFValues()
14951511 zPend -- ;
14961512 while ( true ) {
14971513 switch ( zPend % 2 ) {
1498- case 0 :
1499- szptr [ wr ] = ( short ) BZip2Constants . RunA ;
1500- wr ++ ;
1501- mtfFreq [ BZip2Constants . RunA ] ++ ;
1502- break ;
1503- case 1 :
1504- szptr [ wr ] = ( short ) BZip2Constants . RunB ;
1505- wr ++ ;
1506- mtfFreq [ BZip2Constants . RunB ] ++ ;
1507- break ;
1514+ case 0 :
1515+ szptr [ wr ] = ( short ) BZip2Constants . RunA ;
1516+ wr ++ ;
1517+ mtfFreq [ BZip2Constants . RunA ] ++ ;
1518+ break ;
1519+ case 1 :
1520+ szptr [ wr ] = ( short ) BZip2Constants . RunB ;
1521+ wr ++ ;
1522+ mtfFreq [ BZip2Constants . RunB ] ++ ;
1523+ break ;
15081524 }
15091525 if ( zPend < 2 ) {
15101526 break ;
@@ -1523,16 +1539,16 @@ void GenerateMTFValues()
15231539 zPend -- ;
15241540 while ( true ) {
15251541 switch ( zPend % 2 ) {
1526- case 0 :
1527- szptr [ wr ] = ( short ) BZip2Constants . RunA ;
1528- wr ++ ;
1529- mtfFreq [ BZip2Constants . RunA ] ++ ;
1530- break ;
1531- case 1 :
1532- szptr [ wr ] = ( short ) BZip2Constants . RunB ;
1533- wr ++ ;
1534- mtfFreq [ BZip2Constants . RunB ] ++ ;
1535- break ;
1542+ case 0 :
1543+ szptr [ wr ] = ( short ) BZip2Constants . RunA ;
1544+ wr ++ ;
1545+ mtfFreq [ BZip2Constants . RunA ] ++ ;
1546+ break ;
1547+ case 1 :
1548+ szptr [ wr ] = ( short ) BZip2Constants . RunB ;
1549+ wr ++ ;
1550+ mtfFreq [ BZip2Constants . RunB ] ++ ;
1551+ break ;
15361552 }
15371553 if ( zPend < 2 ) {
15381554 break ;
0 commit comments