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


C# ZipEntry.Compare方法代码示例

本文整理汇总了C#中ZipEntry.Compare方法的典型用法代码示例。如果您正苦于以下问题:C# ZipEntry.Compare方法的具体用法?C# ZipEntry.Compare怎么用?C# ZipEntry.Compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZipEntry的用法示例。


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

示例1: Extract

            public byte[] Extract(bool Preview, String outname = null)
            {
                byte[] databuff;
                int dataoff = 30; // For ZipEntry header - not the above one
                if (Filename != null)
                    dataoff += Filename.Length;
                if (Extra != null)
                    dataoff += Extra.Length;

                // KFreon: Use stored MemoryStream if possible.
                Stream tpf = null;
                if (_par.FileData == null)
                    tpf = new FileStream(_par._filename, FileMode.Open, FileAccess.Read);
                else
                    tpf = new MemoryStream(_par.FileData);

                tpf.Seek(FileOffset, SeekOrigin.Begin);
                databuff = ZipReader.BuffXOR(tpf, dataoff + (int)ComprSize + 16); // XOR the whole data block as well as the footer

                // KFreon: Dispose of stream IF it was a FileStream
                if (_par.FileData == null)
                    tpf.Dispose();

                // Check for correct header data and such
                ZipEntry fileentry = new ZipEntry(databuff);
                if (!fileentry.Compare(this))
                    throw new InvalidDataException("File header not as expected");


                // KFreon: Apparently not necessary. Some TPF's fail to load with this, but when commented out, they load fine, so...
                /*if (BitConverter.ToUInt32(databuff, (int)ComprSize + dataoff) != datadescriptormagic) 
                    Console.WriteLine("Footer not as expected");*/

                databuff = ZipDecrypto.DecryptData(this, databuff, dataoff, (int)ComprSize);

                databuff = Deflate(databuff, 12 + dataoff, (int)ComprSize - 12);
                if (databuff.Length != UncomprSize)
                    throw new InvalidDataException("Deflation resulted in incorrect file size");
                if (CRC32.BlockChecksum(databuff, 0, (int)UncomprSize) != CRC)
                    throw new InvalidDataException("Checksums don't match");

                if (!Preview)
                {
                    outname = outname ?? Filename;
                    using (FileStream fs = new FileStream(outname, FileMode.Create, FileAccess.Write))
                    {
                        fs.Write(databuff, 0, (int)UncomprSize);
                    }
                    return null;
                }
                else
                    return databuff;
            }
开发者ID:KFreon,项目名称:KFreons-ME3Explorer,代码行数:53,代码来源:ZipReader.cs

示例2: Extract

            public byte[] Extract(bool Preview, String outname = null)
            {
                byte[] databuff;
                int dataoff = 30;
                if (Filename != null)
                    dataoff += Filename.Length;
                if (Extra != null)
                    dataoff += Extra.Length;
                using (FileStream tpf = new FileStream(_par._filename, FileMode.Open, FileAccess.Read))
                {
                    tpf.Seek(FileOffset, SeekOrigin.Begin);
                    databuff = ZipReader.BuffXOR(tpf, dataoff + (int)ComprSize + 16); // XOR the whole data block as well as the footer
                }

                // Check for correct header data and such
                ZipEntry fileentry = new ZipEntry(databuff);
                if (!fileentry.Compare(this))
                    throw new InvalidDataException("File header not as expected");
                if (BitConverter.ToUInt32(databuff, (int)ComprSize + dataoff) != datadescriptormagic)
                    throw new InvalidDataException("Footer not as expected");

                //ZipCrypto.DecryptData(this, databuff, dataoff, (int)ComprSize);
                KFreonZipCrypto crypto = new KFreonZipCrypto(this, databuff, dataoff, (int)ComprSize);
                databuff = crypto.GetBlocks();

                databuff = Deflate(databuff, 12 + dataoff, (int)ComprSize - 12);
                if (databuff.Length != UncomprSize)
                    throw new InvalidDataException("Deflation resulted in incorrect file size");
                CRC32 crcgen = new CRC32();
                if (crcgen.BlockChecksum(databuff, 0, (int)UncomprSize) != CRC)
                    throw new InvalidDataException("Checksums don't match");

                if (!Preview)
                {
                    outname = outname ?? Filename;
                    using (FileStream fs = new FileStream(outname, FileMode.Create, FileAccess.Write))
                    {
                        fs.Write(databuff, 0, (int)UncomprSize);
                    }
                    return null;
                }
                else
                    return databuff;
            }
开发者ID:CreeperLava,项目名称:ME3Explorer,代码行数:44,代码来源:ZipReader.cs


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