TrySkipBlock() static public méthode

static public TrySkipBlock ( BinaryReader reader ) : bool
reader BinaryReader
Résultat bool
Exemple #1
0
 private bool IsOpenable(bool needToUncompress, bool needToLoadIntoMemory, out string message)
 {
     message = null;
     if (this._originallyInArchive)
     {
         if (needToUncompress && this.CompressionMethod != ZipArchiveEntry.CompressionMethodValues.Stored && this.CompressionMethod != ZipArchiveEntry.CompressionMethodValues.Deflate)
         {
             message = Messages.UnsupportedCompression;
             return(false);
         }
         if ((long)this._diskNumberStart != (ulong)this._archive.NumberOfThisDisk)
         {
             message = Messages.SplitSpanned;
             return(false);
         }
         if (this._offsetOfLocalHeader > this._archive.ArchiveStream.Length)
         {
             message = Messages.LocalFileHeaderCorrupt;
             return(false);
         }
         this._archive.ArchiveStream.Seek(this._offsetOfLocalHeader, SeekOrigin.Begin);
         if (!ZipLocalFileHeader.TrySkipBlock(this._archive.ArchiveReader))
         {
             message = Messages.LocalFileHeaderCorrupt;
             return(false);
         }
         if (this.OffsetOfCompressedData + this._compressedSize > this._archive.ArchiveStream.Length)
         {
             message = Messages.LocalFileHeaderCorrupt;
             return(false);
         }
         if (needToLoadIntoMemory && this._compressedSize > (long)2147483647)
         {
             message = Messages.EntryTooLarge;
             return(false);
         }
     }
     return(true);
 }
Exemple #2
0
        private bool IsOpenable(bool needToUncompress, bool needToLoadIntoMemory, out string message)
        {
            message = null;

            if (_originallyInArchive)
            {
                if (needToUncompress)
                {
                    if (CompressionMethod != CompressionMethodValues.Stored &&
                        CompressionMethod != CompressionMethodValues.Deflate &&
                        CompressionMethod != CompressionMethodValues.Deflate64)
                    {
                        switch (CompressionMethod)
                        {
                        case CompressionMethodValues.BZip2:
                        case CompressionMethodValues.LZMA:
                            message = "";
                            break;

                        default:
                            message = "";
                            break;
                        }
                        return(false);
                    }
                }
                if (_diskNumberStart != _archive.NumberOfThisDisk)
                {
                    message = "";
                    return(false);
                }
                if (_offsetOfLocalHeader > _archive.ArchiveStream.Length)
                {
                    message = "";
                    return(false);
                }
                _archive.ArchiveStream.Seek(_offsetOfLocalHeader, SeekOrigin.Begin);
                if (!ZipLocalFileHeader.TrySkipBlock(_archive.ArchiveReader))
                {
                    message = "";
                    return(false);
                }
                // when this property gets called, some duplicated work
                if (OffsetOfCompressedData + _compressedSize > _archive.ArchiveStream.Length)
                {
                    message = "";
                    return(false);
                }
                // This limitation originally existed because a) it is unreasonable to load > 4GB into memory
                // but also because the stream reading functions make it hard.  This has been updated to handle
                // this scenario in a 64-bit process using multiple buffers, delivered first as an OOB for
                // compatibility.
                if (needToLoadIntoMemory)
                {
                    if (_compressedSize > int.MaxValue)
                    {
                        if (!s_allowLargeZipArchiveEntriesInUpdateMode)
                        {
                            message = "";
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }