diff --git a/.gitignore b/.gitignore index 2d1bf74c..cd8782e1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ _ReSharper.SharpCompress/ bin/ *.suo +*.user TestArchives/Scratch/ TestArchives/Scratch2/ diff --git a/SharpCompress.Test/SharpCompress.Test.csproj b/SharpCompress.Test/SharpCompress.Test.csproj index 9f619d39..b9ce86c8 100644 --- a/SharpCompress.Test/SharpCompress.Test.csproj +++ b/SharpCompress.Test/SharpCompress.Test.csproj @@ -57,6 +57,7 @@ + diff --git a/SharpCompress.Test/Streams/StreamTests.cs b/SharpCompress.Test/Streams/StreamTests.cs new file mode 100644 index 00000000..fe489e55 --- /dev/null +++ b/SharpCompress.Test/Streams/StreamTests.cs @@ -0,0 +1,21 @@ +using System.IO; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SharpCompress.Compressor.LZMA; + +namespace SharpCompress.Test.Streams +{ + [TestClass] + public class StreamTests + { + [TestMethod] + public void TestLzma2Decompress1Byte() + { + byte[] properties = new byte[] { 0x01 }; + byte[] compressedData = new byte[] { 0x01, 0x00, 0x00, 0x58, 0x00 }; + MemoryStream lzma2Stream = new MemoryStream(compressedData); + + LzmaStream decompressor = new LzmaStream(properties, lzma2Stream, 5, 1); + Assert.AreEqual('X', decompressor.ReadByte()); + } + } +} \ No newline at end of file diff --git a/SharpCompress/Compressor/LZMA/LzmaStream.cs b/SharpCompress/Compressor/LZMA/LzmaStream.cs index 9968ba2a..f9a8aeaf 100644 --- a/SharpCompress/Compressor/LZMA/LzmaStream.cs +++ b/SharpCompress/Compressor/LZMA/LzmaStream.cs @@ -179,13 +179,15 @@ namespace SharpCompress.Compressor.LZMA if (toProcess > availableBytes) toProcess = (int)availableBytes; + outWindow.SetLimit(toProcess); if (uncompressedChunk) - inputPosition += outWindow.CopyStream(inputStream, toProcess); - else { - outWindow.SetLimit(toProcess); - if (decoder.Code(dictionarySize, outWindow, rangeDecoder) && outputSize < 0) - availableBytes = outWindow.AvailableBytes; + inputPosition += outWindow.CopyStream(inputStream, toProcess); + } + else if (decoder.Code(dictionarySize, outWindow, rangeDecoder) + && outputSize < 0) + { + availableBytes = outWindow.AvailableBytes; } int read = outWindow.Read(buffer, offset, toProcess); diff --git a/SharpCompress/SharpCompress.3.5.csproj.user b/SharpCompress/SharpCompress.3.5.csproj.user deleted file mode 100644 index 76fe5a55..00000000 --- a/SharpCompress/SharpCompress.3.5.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - ProjectFiles - - \ No newline at end of file diff --git a/SharpCompress/SharpCompress.Silverlight.csproj.user b/SharpCompress/SharpCompress.Silverlight.csproj.user deleted file mode 100644 index d2cc8df2..00000000 --- a/SharpCompress/SharpCompress.Silverlight.csproj.user +++ /dev/null @@ -1,32 +0,0 @@ - - - - ProjectFiles - - - - - - - - DynamicPage - True - False - False - - - - - - - - - True - - - True - - - - - \ No newline at end of file diff --git a/SharpCompress/SharpCompress.WP7.csproj.user b/SharpCompress/SharpCompress.WP7.csproj.user deleted file mode 100644 index 76fe5a55..00000000 --- a/SharpCompress/SharpCompress.WP7.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - ProjectFiles - - \ No newline at end of file diff --git a/SharpCompress/SharpCompress.WinRT.csproj.user b/SharpCompress/SharpCompress.WinRT.csproj.user deleted file mode 100644 index 76fe5a55..00000000 --- a/SharpCompress/SharpCompress.WinRT.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - ProjectFiles - - \ No newline at end of file diff --git a/SharpCompress/SharpCompress.WindowsStore.csproj.user b/SharpCompress/SharpCompress.WindowsStore.csproj.user deleted file mode 100644 index 566c009a..00000000 --- a/SharpCompress/SharpCompress.WindowsStore.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - ShowAllFiles - - \ No newline at end of file diff --git a/SharpCompress/SharpCompress.csproj.user b/SharpCompress/SharpCompress.csproj.user deleted file mode 100644 index 76fe5a55..00000000 --- a/SharpCompress/SharpCompress.csproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - ProjectFiles - - \ No newline at end of file