diff --git a/ICSharpCode.SharpZipLib/BZip2/BZip2OutputStream.cs b/ICSharpCode.SharpZipLib/BZip2/BZip2OutputStream.cs
index b83a3f778..c18005156 100644
--- a/ICSharpCode.SharpZipLib/BZip2/BZip2OutputStream.cs
+++ b/ICSharpCode.SharpZipLib/BZip2/BZip2OutputStream.cs
@@ -94,7 +94,8 @@ public BZip2OutputStream(Stream stream, int blockSize)
/// Get/set flag indicating ownership of underlying stream.
/// When the flag is true will close the underlying stream also.
///
- public bool IsStreamOwner {
+ public bool IsStreamOwner
+ {
get { return isStreamOwner; }
set { isStreamOwner = value; }
}
@@ -104,8 +105,10 @@ public bool IsStreamOwner {
///
/// Gets a value indicating whether the current stream supports reading
///
- public override bool CanRead {
- get {
+ public override bool CanRead
+ {
+ get
+ {
return false;
}
}
@@ -113,8 +116,10 @@ public override bool CanRead {
///
/// Gets a value indicating whether the current stream supports seeking
///
- public override bool CanSeek {
- get {
+ public override bool CanSeek
+ {
+ get
+ {
return false;
}
}
@@ -122,8 +127,10 @@ public override bool CanSeek {
///
/// Gets a value indicating whether the current stream supports writing
///
- public override bool CanWrite {
- get {
+ public override bool CanWrite
+ {
+ get
+ {
return baseStream.CanWrite;
}
}
@@ -131,8 +138,10 @@ public override bool CanWrite {
///
/// Gets the length in bytes of the stream
///
- public override long Length {
- get {
+ public override long Length
+ {
+ get
+ {
return baseStream.Length;
}
}
@@ -140,11 +149,14 @@ public override long Length {
///
/// Gets or sets the current position of this stream.
///
- public override long Position {
- get {
+ public override long Position
+ {
+ get
+ {
return baseStream.Position;
}
- set {
+ set
+ {
throw new NotSupportedException("BZip2OutputStream position cannot be set");
}
}
@@ -282,37 +294,37 @@ void WriteRun()
}
switch (runLength) {
- case 1:
- last++;
- block[last + 1] = (byte)currentChar;
- break;
- case 2:
- last++;
- block[last + 1] = (byte)currentChar;
- last++;
- block[last + 1] = (byte)currentChar;
- break;
- case 3:
- last++;
- block[last + 1] = (byte)currentChar;
- last++;
- block[last + 1] = (byte)currentChar;
- last++;
- block[last + 1] = (byte)currentChar;
- break;
- default:
- inUse[runLength - 4] = true;
- last++;
- block[last + 1] = (byte)currentChar;
- last++;
- block[last + 1] = (byte)currentChar;
- last++;
- block[last + 1] = (byte)currentChar;
- last++;
- block[last + 1] = (byte)currentChar;
- last++;
- block[last + 1] = (byte)(runLength - 4);
- break;
+ case 1:
+ last++;
+ block[last + 1] = (byte)currentChar;
+ break;
+ case 2:
+ last++;
+ block[last + 1] = (byte)currentChar;
+ last++;
+ block[last + 1] = (byte)currentChar;
+ break;
+ case 3:
+ last++;
+ block[last + 1] = (byte)currentChar;
+ last++;
+ block[last + 1] = (byte)currentChar;
+ last++;
+ block[last + 1] = (byte)currentChar;
+ break;
+ default:
+ inUse[runLength - 4] = true;
+ last++;
+ block[last + 1] = (byte)currentChar;
+ last++;
+ block[last + 1] = (byte)currentChar;
+ last++;
+ block[last + 1] = (byte)currentChar;
+ last++;
+ block[last + 1] = (byte)currentChar;
+ last++;
+ block[last + 1] = (byte)(runLength - 4);
+ break;
}
} else {
EndBlock();
@@ -324,7 +336,8 @@ void WriteRun()
///
/// Get the number of bytes written to the output.
///
- public int BytesWritten {
+ public int BytesWritten
+ {
get { return bytesOut; }
}
@@ -335,25 +348,28 @@ public int BytesWritten {
override protected void Dispose(bool disposing)
{
try {
- base.Dispose(disposing);
- if (!disposed_) {
- disposed_ = true;
+ try {
+ base.Dispose(disposing);
+ if (!disposed_) {
+ disposed_ = true;
- if (runLength > 0) {
- WriteRun();
- }
+ if (runLength > 0) {
+ WriteRun();
+ }
- currentChar = -1;
- EndBlock();
- EndCompression();
- Flush();
- }
- } finally {
- if (disposing) {
- if (IsStreamOwner) {
- baseStream.Close();
+ currentChar = -1;
+ EndBlock();
+ EndCompression();
+ Flush();
+ }
+ } finally {
+ if (disposing) {
+ if (IsStreamOwner) {
+ baseStream.Close();
+ }
}
}
+ } catch {
}
}
@@ -1495,16 +1511,16 @@ void GenerateMTFValues()
zPend--;
while (true) {
switch (zPend % 2) {
- case 0:
- szptr[wr] = (short)BZip2Constants.RunA;
- wr++;
- mtfFreq[BZip2Constants.RunA]++;
- break;
- case 1:
- szptr[wr] = (short)BZip2Constants.RunB;
- wr++;
- mtfFreq[BZip2Constants.RunB]++;
- break;
+ case 0:
+ szptr[wr] = (short)BZip2Constants.RunA;
+ wr++;
+ mtfFreq[BZip2Constants.RunA]++;
+ break;
+ case 1:
+ szptr[wr] = (short)BZip2Constants.RunB;
+ wr++;
+ mtfFreq[BZip2Constants.RunB]++;
+ break;
}
if (zPend < 2) {
break;
@@ -1523,16 +1539,16 @@ void GenerateMTFValues()
zPend--;
while (true) {
switch (zPend % 2) {
- case 0:
- szptr[wr] = (short)BZip2Constants.RunA;
- wr++;
- mtfFreq[BZip2Constants.RunA]++;
- break;
- case 1:
- szptr[wr] = (short)BZip2Constants.RunB;
- wr++;
- mtfFreq[BZip2Constants.RunB]++;
- break;
+ case 0:
+ szptr[wr] = (short)BZip2Constants.RunA;
+ wr++;
+ mtfFreq[BZip2Constants.RunA]++;
+ break;
+ case 1:
+ szptr[wr] = (short)BZip2Constants.RunB;
+ wr++;
+ mtfFreq[BZip2Constants.RunB]++;
+ break;
}
if (zPend < 2) {
break;
diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/PendingBuffer.cs b/ICSharpCode.SharpZipLib/Zip/Compression/PendingBuffer.cs
index f1f323a5e..de9246e2f 100644
--- a/ICSharpCode.SharpZipLib/Zip/Compression/PendingBuffer.cs
+++ b/ICSharpCode.SharpZipLib/Zip/Compression/PendingBuffer.cs
@@ -245,6 +245,8 @@ public int Flush(byte[] output, int offset, int length)
///
public byte[] ToByteArray()
{
+ AlignToByte();
+
byte[] result = new byte[end - start];
System.Array.Copy(buffer_, start, result, 0, result.Length);
start = 0;
diff --git a/ICSharpCode.SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs b/ICSharpCode.SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs
index 1ac219d0e..70c0b7b2c 100644
--- a/ICSharpCode.SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs
+++ b/ICSharpCode.SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs
@@ -481,7 +481,8 @@ public override bool CanWrite {
///
public override long Length {
get {
- return inputBuffer.RawLength;
+ //return inputBuffer.RawLength;
+ throw new NotSupportedException("InflaterInputStream Length is not supported");
}
}