当前位置: 首页>>代码示例>>C#>>正文


C# ReadDataHandler类代码示例

本文整理汇总了C#中ReadDataHandler的典型用法代码示例。如果您正苦于以下问题:C# ReadDataHandler类的具体用法?C# ReadDataHandler怎么用?C# ReadDataHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ReadDataHandler类属于命名空间,在下文中一共展示了ReadDataHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Close

        /// <summary>
        /// Closes the zip input stream
        /// </summary>
        public override void Close()
        {
            internalReader = new ReadDataHandler(ReadingNotAvailable);
            crc = null;
            entry = null;

            base.Close();
        }
开发者ID:svn2github,项目名称:tvdblib,代码行数:11,代码来源:ZipInputStream.cs

示例2: GetNextEntry

        public ZipEntry GetNextEntry()
        {
            if (crc == null) {
                throw new InvalidOperationException("Closed.");
            }

            if (entry != null) {
                CloseEntry();
            }

            int header = inputBuffer.ReadLeInt();

            if (header == ZipConstants.CentralHeaderSignature ||
                header == ZipConstants.EndOfCentralDirectorySignature ||
                header == ZipConstants.CentralHeaderDigitalSignature ||
                header == ZipConstants.ArchiveExtraDataSignature ||
                header == ZipConstants.Zip64CentralFileHeaderSignature) {

                Close();
                return null;
            }

            if ( (header == ZipConstants.SpanningTempSignature) || (header == ZipConstants.SpanningSignature) ) {
                header = inputBuffer.ReadLeInt();
            }

            if (header != ZipConstants.LocalHeaderSignature) {
                throw new ZipException("Wrong Local header signature: 0x" + String.Format("{0:X}", header));
            }

            short versionRequiredToExtract = (short)inputBuffer.ReadLeShort();

            flags          = inputBuffer.ReadLeShort();
            method         = inputBuffer.ReadLeShort();
            uint dostime   = (uint)inputBuffer.ReadLeInt();
            int crc2       = inputBuffer.ReadLeInt();
            csize          = inputBuffer.ReadLeInt();
            size           = inputBuffer.ReadLeInt();
            int nameLen    = inputBuffer.ReadLeShort();
            int extraLen   = inputBuffer.ReadLeShort();

            bool isCrypted = (flags & 1) == 1;

            byte[] buffer = new byte[nameLen];
            inputBuffer.ReadRawBuffer(buffer);

            string name = ZipConstants.ConvertToStringExt(flags, buffer);

            entry = new ZipEntry(name, versionRequiredToExtract);
            entry.Flags = flags;

            entry.CompressionMethod = (CompressionMethod)method;

            if ((flags & 8) == 0) {
                entry.Crc  = crc2 & 0xFFFFFFFFL;
                entry.Size = size & 0xFFFFFFFFL;
                entry.CompressedSize = csize & 0xFFFFFFFFL;

                entry.CryptoCheckValue = (byte)((crc2 >> 24) & 0xff);

            } else {

                if (crc2 != 0) {
                    entry.Crc = crc2 & 0xFFFFFFFFL;
                }

                if (size != 0) {
                    entry.Size = size & 0xFFFFFFFFL;
                }

                if (csize != 0) {
                    entry.CompressedSize = csize & 0xFFFFFFFFL;
                }

                entry.CryptoCheckValue = (byte)((dostime >> 8) & 0xff);
            }

            entry.DosTime = dostime;

            if (extraLen > 0) {
                byte[] extra = new byte[extraLen];
                inputBuffer.ReadRawBuffer(extra);
                entry.ExtraData = extra;
            }

            entry.ProcessExtraData(true);
            if ( entry.CompressedSize >= 0 ) {
                csize = entry.CompressedSize;
            }

            if ( entry.Size >= 0 ) {
                size = entry.Size;
            }

            if (method == (int)CompressionMethod.Stored && (!isCrypted && csize != size || (isCrypted && csize - ZipConstants.CryptoHeaderSize != size))) {
                throw new ZipException("Stored, but compressed != uncompressed");
            }

            if (entry.IsCompressionMethodSupported()) {
                internalReader = new ReadDataHandler(InitialRead);
//.........这里部分代码省略.........
开发者ID:NoobSkie,项目名称:taobao-shop-helper,代码行数:101,代码来源:ZipInputStream.cs

示例3: ZipInputStream

 /// <summary>
 /// Creates a new Zip input stream, for reading a zip archive.
 /// </summary>
 /// <param name="baseInputStream">The underlying <see cref="Stream"/> providing data.</param>
 public ZipInputStream(Stream baseInputStream)
     : base(baseInputStream, new Inflater(true))
 {
     internalReader = new ReadDataHandler(ReadingNotAvailable);
 }
开发者ID:svn2github,项目名称:tvdblib,代码行数:9,代码来源:ZipInputStream.cs

示例4: InitialRead

 private int InitialRead(byte[] destination, int offset, int count)
 {
     if (!this.CanDecompressEntry)
     {
         throw new ZipException("Library cannot extract this entry. Version required is (" + this.entry.Version.ToString() + ")");
     }
     if (this.entry.IsCrypted)
     {
         if (this.password == null)
         {
             throw new ZipException("No password set.");
         }
         PkzipClassicManaged managed = new PkzipClassicManaged();
         byte[] rgbKey = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(this.password));
         base.inputBuffer.CryptoTransform = managed.CreateDecryptor(rgbKey, null);
         byte[] outBuffer = new byte[12];
         base.inputBuffer.ReadClearTextBuffer(outBuffer, 0, 12);
         if (outBuffer[11] != this.entry.CryptoCheckValue)
         {
             throw new ZipException("Invalid password");
         }
         if (base.csize < 12L)
         {
             if ((this.entry.Flags & 8) == 0)
             {
                 throw new ZipException(string.Format("Entry compressed size {0} too small for encryption", base.csize));
             }
         }
         else
         {
             base.csize -= 12L;
         }
     }
     else
     {
         base.inputBuffer.CryptoTransform = null;
     }
     if ((base.csize > 0L) || ((this.flags & 8) != 0))
     {
         if ((this.method == 8) && (base.inputBuffer.Available > 0))
         {
             base.inputBuffer.SetInflaterInput(base.inf);
         }
         this.internalReader = new ReadDataHandler(this.BodyRead);
         return this.BodyRead(destination, offset, count);
     }
     this.internalReader = new ReadDataHandler(this.ReadingNotAvailable);
     return 0;
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:49,代码来源:ZipInputStream.cs

示例5: InitialRead

        /// <summary>
        /// Perform the initial read on an entry which may include 
        /// reading encryption headers and setting up inflation.
        /// </summary>
        /// <param name="destination">The destination to fill with data read.</param>
        /// <param name="offset">The offset to start reading at.</param>
        /// <param name="count">The maximum number of bytes to read.</param>
        /// <returns>The actual number of bytes read.</returns>
        int InitialRead(byte[] destination, int offset, int count)
        {
            if ( !CanDecompressEntry ) {
                throw new ZipException("Library cannot extract this entry. Version required is (" + entry.Version.ToString() + ")");
            }

            // Handle encryption if required.
            if (entry.IsCrypted) {

                throw new ZipException("Encryption not supported for Compact Framework 1.0");
            } else {
            }

            if ((csize > 0) || ((flags & (int)GeneralBitFlags.Descriptor) != 0)) {
                if ((method == (int)CompressionMethod.Deflated) && (inputBuffer.Available > 0)) {
                    inputBuffer.SetInflaterInput(inf);
                }

                internalReader = new ReadDataHandler(BodyRead);
                return BodyRead(destination, offset, count);
            }
            else {
                internalReader = new ReadDataHandler(ReadingNotAvailable);
                return 0;
            }
        }
开发者ID:nobud,项目名称:Variant-Report,代码行数:34,代码来源:ZipInputStream.cs

示例6: GetNextEntry

        public ZipEntry GetNextEntry()
        {
            if (this.crc == null)
            {
                throw new InvalidOperationException("Closed.");
            }
            if (this.entry != null)
            {
                this.CloseEntry();
            }
            int num = base.inputBuffer.ReadLeInt();
            switch (num)
            {
                case 0x2014b50:
                case 0x6054b50:
                case 0x5054b50:
                case 0x7064b50:
                case 0x6064b50:
                    this.Close();
                    return null;

                case 0x30304b50:
                case 0x8074b50:
                    num = base.inputBuffer.ReadLeInt();
                    break;
            }
            if (num != 0x4034b50)
            {
                throw new ZipException("Wrong Local header signature: 0x" + string.Format("{0:X}", num));
            }
            short versionRequiredToExtract = (short) base.inputBuffer.ReadLeShort();
            this.flags = base.inputBuffer.ReadLeShort();
            this.method = base.inputBuffer.ReadLeShort();
            uint num3 = (uint) base.inputBuffer.ReadLeInt();
            int num4 = base.inputBuffer.ReadLeInt();
            base.csize = base.inputBuffer.ReadLeInt();
            this.size = base.inputBuffer.ReadLeInt();
            int num5 = base.inputBuffer.ReadLeShort();
            int num6 = base.inputBuffer.ReadLeShort();
            bool flag = (this.flags & 1) == 1;
            byte[] buffer = new byte[num5];
            base.inputBuffer.ReadRawBuffer(buffer);
            string name = ZipConstants.ConvertToStringExt(this.flags, buffer);
            this.entry = new ZipEntry(name, versionRequiredToExtract);
            this.entry.Flags = this.flags;
            this.entry.CompressionMethod = (CompressionMethod) this.method;
            if ((this.flags & 8) == 0)
            {
                this.entry.Crc = num4 & ((long) 0xffffffffL);
                this.entry.Size = this.size & ((long) 0xffffffffL);
                this.entry.CompressedSize = base.csize & ((long) 0xffffffffL);
                this.entry.CryptoCheckValue = (byte) ((num4 >> 0x18) & 0xff);
            }
            else
            {
                if (num4 != 0)
                {
                    this.entry.Crc = num4 & ((long) 0xffffffffL);
                }
                if (this.size != 0L)
                {
                    this.entry.Size = this.size & ((long) 0xffffffffL);
                }
                if (base.csize != 0L)
                {
                    this.entry.CompressedSize = base.csize & ((long) 0xffffffffL);
                }
                this.entry.CryptoCheckValue = (byte) ((num3 >> 8) & 0xff);
            }
            this.entry.DosTime = num3;
            if (num6 > 0)
            {
                byte[] buffer2 = new byte[num6];
                base.inputBuffer.ReadRawBuffer(buffer2);
                this.entry.ExtraData = buffer2;
            }
            this.entry.ProcessExtraData(true);
            if (this.entry.CompressedSize >= 0L)
            {
                base.csize = this.entry.CompressedSize;
            }
            if (this.entry.Size >= 0L)
            {
                this.size = this.entry.Size;
            }
            if ((this.method == 0) && ((!flag && (base.csize != this.size)) || (flag && ((base.csize - 12L) != this.size))))
            {
                throw new ZipException("Stored, but compressed != uncompressed");
            }
            if (this.entry.IsCompressionMethodSupported())
            {
                this.internalReader = new ReadDataHandler(this.InitialRead);
            }
            else
            {
                this.internalReader = new ReadDataHandler(this.ReadingNotSupported);
            }
            return this.entry;
        }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:99,代码来源:ZipInputStream.cs

示例7: ZipInputStream

 public ZipInputStream(Stream baseInputStream, int bufferSize) : base(baseInputStream, new Inflater(true), bufferSize)
 {
     this.crc = new Crc32();
     this.internalReader = new ReadDataHandler(this.ReadingNotAvailable);
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:5,代码来源:ZipInputStream.cs

示例8: Close

 public override void Close()
 {
     this.internalReader = new ReadDataHandler(this.ReadingNotAvailable);
     this.crc = null;
     this.entry = null;
     base.Close();
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:7,代码来源:ZipInputStream.cs

示例9: Dispose

 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         internalReader = new ReadDataHandler(ReadingNotAvailable);
         crc = null;
         entry = null;
     }
     base.Dispose(disposing);
 }
开发者ID:JoeCooper,项目名称:SharpZipLib.Portable,代码行数:10,代码来源:ZipInputStream.cs

示例10: InitialRead

        int InitialRead(byte[] destination, int offset, int count)
        {
            if (entry.IsCrypted) {
            #if NETCF_1_0
                throw new ZipException("Encryption not supported for Compact Framework 1.0");
            #else

                PkzipClassicManaged managed = new PkzipClassicManaged();
                byte[] key = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(password));

                inputBuffer.CryptoTransform = managed.CreateDecryptor(key, null);

                byte[] cryptbuffer = new byte[ZipConstants.CryptoHeaderSize];
                inputBuffer.ReadClearTextBuffer(cryptbuffer, 0, ZipConstants.CryptoHeaderSize);

                if (csize >= ZipConstants.CryptoHeaderSize) {
                    csize -= ZipConstants.CryptoHeaderSize;
                }

            #endif
            } else {
            #if !NETCF_1_0
                inputBuffer.CryptoTransform = null;
            #endif
            }

            if ((csize > 0) || ((flags & (int)GeneralBitFlags.Descriptor) != 0)) {
                if ((method == (int)CompressionMethod.Deflated) && (inputBuffer.Available > 0)) {
                    inputBuffer.SetInflaterInput(inf);
                }

                internalReader = new ReadDataHandler(BodyRead);
                return BodyRead(destination, offset, count);
            }
            else {
                internalReader = new ReadDataHandler(ReadingNotAvailable);
                return 0;
            }
        }
开发者ID:Mikolaytis,项目名称:Mikolaytis,代码行数:39,代码来源:ZipInputStream.cs

示例11: InitialRead

        /// <summary>
        /// Perform the initial read on an entry which may include 
        /// reading encryption headers and setting up inflation.
        /// </summary>
        /// <param name="destination">The destination to fill with data read.</param>
        /// <param name="offset">The offset to start reading at.</param>
        /// <param name="count">The maximum number of bytes to read.</param>
        /// <returns>The actual number of bytes read.</returns>
        int InitialRead(byte[] destination, int offset, int count)
        {
            if ( !CanDecompressEntry ) {
                throw new ZipException("Library cannot extract this entry. Version required is (" + entry.Version.ToString() + ")");
            }

            // Handle encryption if required.
            if (entry.IsCrypted) {
            #if NETCF_1_0
                throw new ZipException("Encryption not supported for Compact Framework 1.0");
            #else
                if (password == null) {
                    throw new ZipException("No password set.");
                }

                // Generate and set crypto transform...
                PkzipClassicManaged managed = new PkzipClassicManaged();
                byte[] key = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(password));

                inputBuffer.CryptoTransform = managed.CreateDecryptor(key, null);

                byte[] cryptbuffer = new byte[ZipConstants.CryptoHeaderSize];
                inputBuffer.ReadClearTextBuffer(cryptbuffer, 0, ZipConstants.CryptoHeaderSize);

                if (cryptbuffer[ZipConstants.CryptoHeaderSize - 1] != entry.CryptoCheckValue) {
                    throw new ZipException("Invalid password");
                }

                if (csize >= ZipConstants.CryptoHeaderSize) {
                    csize -= ZipConstants.CryptoHeaderSize;
                }
                else if ( (entry.Flags & (int)GeneralBitFlags.Descriptor) == 0 ) {
                    throw new ZipException(string.Format("Entry compressed size {0} too small for encryption", csize));
                }
            #endif
            } else {
            #if !NETCF_1_0
                inputBuffer.CryptoTransform = null;
            #endif
            }

            if ((csize > 0) || ((flags & (int)GeneralBitFlags.Descriptor) != 0)) {
                if ((method == (int)CompressionMethod.Deflated) && (inputBuffer.Available > 0)) {
                    inputBuffer.SetInflaterInput(inf);
                }

                internalReader = new ReadDataHandler(BodyRead);
                return BodyRead(destination, offset, count);
            }
            else {
                internalReader = new ReadDataHandler(ReadingNotAvailable);
                return 0;
            }
        }
开发者ID:svn2github,项目名称:tvdblib,代码行数:62,代码来源:ZipInputStream.cs

示例12: ZipInputStream

 /// <summary>
 ///     Creates a new Zip input stream, for reading a zip archive.
 /// </summary>
 /// <param name="baseInputStream">The underlying <see cref="Stream" /> providing data.</param>
 /// <param name="bufferSize">Size of the buffer.</param>
 public ZipInputStream(Stream baseInputStream, int bufferSize)
     : base(baseInputStream, new Inflater(true), bufferSize)
 {
     internalReader = ReadingNotAvailable;
 }
开发者ID:XLPE,项目名称:imewlconverter,代码行数:10,代码来源:ZipInputStream.cs

示例13: Close

        /// <summary>
        ///     Closes the zip input stream
        /// </summary>
        public override void Close()
        {
            internalReader = ReadingNotAvailable;
            crc = null;
            entry = null;

            base.Close();
        }
开发者ID:XLPE,项目名称:imewlconverter,代码行数:11,代码来源:ZipInputStream.cs

示例14: GetNextEntry

        public ZipEntry GetNextEntry()
        {
            if (_crc == null)
            {
                throw new InvalidOperationException("Closed.");
            }
            if (_entry != null)
            {
                CloseEntry();
            }
            var num = InputBuffer.ReadLeInt();
            switch (num)
            {
                case ZipConstants.CentralHeaderSignature:
                case ZipConstants.EndOfCentralDirectorySignature:
                case ZipConstants.CentralHeaderDigitalSignature:
                case ZipConstants.ArchiveExtraDataSignature:
                case 0x6064b50:
                    Close();
                    return null;

                case 0x30304b50:
                case ZipConstants.SpanningSignature:
                    num = InputBuffer.ReadLeInt();
                    break;
            }
            if (num != ZipConstants.LocalHeaderSignature)
            {
                throw new ZipException("Wrong Local header signature: 0x" + $"{num:X}");
            }
            var versionRequiredToExtract = (short)InputBuffer.ReadLeShort();
            _flags = InputBuffer.ReadLeShort();
            _method = InputBuffer.ReadLeShort();
            var num3 = (uint)InputBuffer.ReadLeInt();
            var num4 = InputBuffer.ReadLeInt();
            Csize = InputBuffer.ReadLeInt();
            _size = InputBuffer.ReadLeInt();
            var num5 = InputBuffer.ReadLeShort();
            var num6 = InputBuffer.ReadLeShort();
            var flag = (_flags & 1) == 1;
            var buffer = new byte[num5];
            InputBuffer.ReadRawBuffer(buffer);
            var name = ZipConstants.ConvertToStringExt(_flags, buffer);
            _entry = new ZipEntry(name, versionRequiredToExtract)
            {
                Flags = _flags,
                CompressionMethod = (CompressionMethod) _method
            };
            if ((_flags & 8) == 0)
            {
                _entry.Crc = num4 & 0xffffffffL;
                _entry.Size = _size & 0xffffffffL;
                _entry.CompressedSize = Csize & 0xffffffffL;
                _entry.CryptoCheckValue = (byte)((num4 >> 0x18) & 0xff);
            }
            else
            {
                if (num4 != 0)
                {
                    _entry.Crc = num4 & 0xffffffffL;
                }
                if (_size != 0L)
                {
                    _entry.Size = _size & 0xffffffffL;
                }
                if (Csize != 0L)
                {
                    _entry.CompressedSize = Csize & 0xffffffffL;
                }
                _entry.CryptoCheckValue = (byte)((num3 >> 8) & 0xff);
            }
            _entry.DosTime = num3;
            if (num6 > 0)
            {
                var buffer2 = new byte[num6];
                InputBuffer.ReadRawBuffer(buffer2);
                _entry.ExtraData = buffer2;
            }
            _entry.ProcessExtraData(true);
            if (_entry.CompressedSize >= 0L)
            {
                Csize = _entry.CompressedSize;
            }
            if (_entry.Size >= 0L)
            {
                _size = _entry.Size;
            }
            if ((_method == 0) && ((!flag && (Csize != _size)) || (flag && ((Csize - 12L) != _size))))
            {
                throw new ZipException("Stored, but compressed != uncompressed");
            }
            if (_entry.IsCompressionMethodSupported())
            {
                _internalReader = InitialRead;
            }
            else
            {
                _internalReader = ReadingNotSupported;
            }
            return _entry;
//.........这里部分代码省略.........
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:101,代码来源:ZipInputStream.cs

示例15: InitialRead

 private int InitialRead(byte[] destination, int offset, int count)
 {
     if (!CanDecompressEntry)
     {
         throw new ZipException("Library cannot extract this entry. Version required is (" 
             + _entry.Version + ")");
     }
     if (_entry.IsCrypted)
     {
         if (_password == null)
         {
             throw new ZipException("No password set.");
         }
         var managed = new PkzipClassicManaged();
         var rgbKey = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(_password));
         InputBuffer.CryptoTransform = managed.CreateDecryptor(rgbKey, null);
         var outBuffer = new byte[12];
         InputBuffer.ReadClearTextBuffer(outBuffer, 0, 12);
         if (outBuffer[11] != _entry.CryptoCheckValue)
         {
             throw new ZipException("Invalid password");
         }
         if (Csize < 12L)
         {
             if ((_entry.Flags & 8) == 0)
             {
                 throw new ZipException($"Entry compressed size {Csize} too small for encryption");
             }
         }
         else
         {
             Csize -= 12L;
         }
     }
     else
     {
         InputBuffer.CryptoTransform = null;
     }
     if ((Csize > 0L) || ((_flags & 8) != 0))
     {
         if ((_method == 8) && (InputBuffer.Available > 0))
         {
             InputBuffer.SetInflaterInput(Inf);
         }
         _internalReader = BodyRead;
         return BodyRead(destination, offset, count);
     }
     _internalReader = ReadingNotAvailable;
     return 0;
 }
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:50,代码来源:ZipInputStream.cs


注:本文中的ReadDataHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。