@@ -9,58 +9,69 @@ namespace ICSharpCode.SharpZipLib.BZip2
9
9
public static class BZip2
10
10
{
11
11
/// <summary>
12
- /// Decompress the <paramref name="inStream">input</paramref> writing
12
+ /// Decompress the <paramref name="inStream">input</paramref> writing
13
13
/// uncompressed data to the <paramref name="outStream">output stream</paramref>
14
14
/// </summary>
15
15
/// <param name="inStream">The readable stream containing data to decompress.</param>
16
16
/// <param name="outStream">The output stream to receive the decompressed data.</param>
17
17
/// <param name="isStreamOwner">Both streams are closed on completion if true.</param>
18
18
public static void Decompress ( Stream inStream , Stream outStream , bool isStreamOwner )
19
19
{
20
- if ( inStream == null || outStream == null ) {
20
+ if ( inStream == null || outStream == null )
21
+ {
21
22
throw new Exception ( "Null Stream" ) ;
22
23
}
23
24
24
- try {
25
- using ( BZip2InputStream bzipInput = new BZip2InputStream ( inStream ) ) {
25
+ try
26
+ {
27
+ using ( BZip2InputStream bzipInput = new BZip2InputStream ( inStream ) )
28
+ {
26
29
bzipInput . IsStreamOwner = isStreamOwner ;
27
30
Core . StreamUtils . Copy ( bzipInput , outStream , new byte [ 4096 ] ) ;
28
31
}
29
- } finally {
30
- if ( isStreamOwner ) {
32
+ }
33
+ finally
34
+ {
35
+ if ( isStreamOwner )
36
+ {
31
37
// inStream is closed by the BZip2InputStream if stream owner
32
38
outStream . Dispose ( ) ;
33
39
}
34
40
}
35
41
}
36
42
37
43
/// <summary>
38
- /// Compress the <paramref name="inStream">input stream</paramref> sending
44
+ /// Compress the <paramref name="inStream">input stream</paramref> sending
39
45
/// result data to <paramref name="outStream">output stream</paramref>
40
46
/// </summary>
41
47
/// <param name="inStream">The readable stream to compress.</param>
42
48
/// <param name="outStream">The output stream to receive the compressed data.</param>
43
49
/// <param name="isStreamOwner">Both streams are closed on completion if true.</param>
44
- /// <param name="level">Block size acts as compression level (1 to 9) with 1 giving
50
+ /// <param name="level">Block size acts as compression level (1 to 9) with 1 giving
45
51
/// the lowest compression and 9 the highest.</param>
46
52
public static void Compress ( Stream inStream , Stream outStream , bool isStreamOwner , int level )
47
53
{
48
- if ( inStream == null || outStream == null ) {
54
+ if ( inStream == null || outStream == null )
55
+ {
49
56
throw new Exception ( "Null Stream" ) ;
50
57
}
51
58
52
- try {
53
- using ( BZip2OutputStream bzipOutput = new BZip2OutputStream ( outStream , level ) ) {
59
+ try
60
+ {
61
+ using ( BZip2OutputStream bzipOutput = new BZip2OutputStream ( outStream , level ) )
62
+ {
54
63
bzipOutput . IsStreamOwner = isStreamOwner ;
55
64
Core . StreamUtils . Copy ( inStream , bzipOutput , new byte [ 4096 ] ) ;
56
65
}
57
- } finally {
58
- if ( isStreamOwner ) {
66
+ }
67
+ finally
68
+ {
69
+ if ( isStreamOwner )
70
+ {
59
71
// outStream is closed by the BZip2OutputStream if stream owner
60
72
inStream . Dispose ( ) ;
61
73
}
62
74
}
63
75
}
64
-
65
76
}
66
77
}
0 commit comments