This filter stream is used to decompress a LZW format stream. Specifically, a stream that uses the LZC compression method. This file format is usually associated with the .Z file extension. See http://en.wikipedia.org/wiki/Compress See http://wiki.wxwidgets.org/Development:_Z_File_Format The file header consists of 3 (or optionally 4) bytes. The first two bytes contain the magic marker "0x1f 0x9d", followed by a byte of flags. Based on Java code by Ronald Tschalar, which in turn was based on the unlzw.c code in the gzip package.
Наследование: Stream
Пример #1
0
        public void InputStreamOwnership()
        {
            var memStream = new TrackedMemoryStream();
            var s = new LzwInputStream(memStream);

            Assert.IsFalse(memStream.IsClosed, "Shouldnt be closed initially");
            Assert.IsFalse(memStream.IsDisposed, "Shouldnt be disposed initially");

            s.Close();

            Assert.IsTrue(memStream.IsClosed, "Should be closed after parent owner close");
            Assert.IsTrue(memStream.IsDisposed, "Should be disposed after parent owner close");

            memStream = new TrackedMemoryStream();
            s = new LzwInputStream(memStream);

            Assert.IsFalse(memStream.IsClosed, "Shouldnt be closed initially");
            Assert.IsFalse(memStream.IsDisposed, "Shouldnt be disposed initially");

            s.IsStreamOwner = false;
            s.Close();

            Assert.IsFalse(memStream.IsClosed, "Should not be closed after parent owner close");
            Assert.IsFalse(memStream.IsDisposed, "Should not be disposed after parent owner close");
        }
Пример #2
0
        public void ZeroLengthInputStream()
        {
            var lis = new LzwInputStream(new MemoryStream());
            bool exception = false;
            try {
                lis.ReadByte();
            } catch {
                exception = true;
            }

            Assert.IsTrue(exception, "reading from an empty stream should cause an exception");
        }