Skip to content

Commit c88def5

Browse files
committed
[wip] bzip2
1 parent 4f541a4 commit c88def5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/ICSharpCode.SharpZipLib/Zip/ZipEntry.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,8 @@ public static bool IsCompressionMethodSupported(CompressionMethod method)
12781278
{
12791279
return
12801280
(method == CompressionMethod.Deflated) ||
1281-
(method == CompressionMethod.Stored);
1281+
(method == CompressionMethod.Stored) ||
1282+
(method == CompressionMethod.BZip2);
12821283
}
12831284

12841285
/// <summary>

src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,10 @@ public Stream GetInputStream(long entryIndex)
882882
result = new InflaterInputStream(result, new Inflater(true));
883883
break;
884884

885+
case CompressionMethod.BZip2:
886+
result = new BZip2.BZip2InputStream(result);
887+
break;
888+
885889
default:
886890
throw new ZipException("Unsupported compression method " + method);
887891
}
@@ -2580,6 +2584,14 @@ private Stream GetOutputStream(ZipEntry entry)
25802584
result = dos;
25812585
break;
25822586

2587+
case CompressionMethod.BZip2:
2588+
var bzos = new BZip2.BZip2OutputStream(result)
2589+
{
2590+
IsStreamOwner = false
2591+
};
2592+
result = bzos;
2593+
break;
2594+
25832595
default:
25842596
throw new ZipException("Unknown compression method " + entry.CompressionMethod);
25852597
}

0 commit comments

Comments
 (0)