예제 #1
0
 internal bool LoadLocalHeaderExtraFieldAndCompressedBytesIfNeeded()
 {
     if (_originallyInArchive)
     {
         _archive.ArchiveStream.Seek(_offsetOfLocalHeader, SeekOrigin.Begin);
         _lhUnknownExtraFields = ZipLocalFileHeader.GetExtraFields(_archive.ArchiveReader);
     }
     if (!_everOpenedForWrite && _originallyInArchive)
     {
         _compressedBytes = new byte[_compressedSize];
         _archive.ArchiveStream.Seek(OffsetOfCompressedData, SeekOrigin.Begin);
         ZipHelper.ReadBytes(_archive.ArchiveStream, _compressedBytes, (int)_compressedSize);
     }
     return(true);
 }
예제 #2
0
 private bool IsOpenable(bool needToUncompress, bool needToLoadIntoMemory, out string message)
 {
     message = null;
     if (_originallyInArchive)
     {
         if ((needToUncompress && (CompressionMethod != CompressionMethodValues.Stored)) && (CompressionMethod != CompressionMethodValues.Deflate))
         {
             message = Messages.UnsupportedCompression;
             return(false);
         }
         if (_diskNumberStart != _archive.NumberOfThisDisk)
         {
             message = Messages.SplitSpanned;
             return(false);
         }
         if (_offsetOfLocalHeader > _archive.ArchiveStream.Length)
         {
             message = Messages.LocalFileHeaderCorrupt;
             return(false);
         }
         _archive.ArchiveStream.Seek(_offsetOfLocalHeader, SeekOrigin.Begin);
         if (!ZipLocalFileHeader.TrySkipBlock(_archive.ArchiveReader))
         {
             message = Messages.LocalFileHeaderCorrupt;
             return(false);
         }
         if ((OffsetOfCompressedData + _compressedSize) > _archive.ArchiveStream.Length)
         {
             message = Messages.LocalFileHeaderCorrupt;
             return(false);
         }
         if (needToLoadIntoMemory && (_compressedSize > 0x7fffffffL))
         {
             message = Messages.EntryTooLarge;
             return(false);
         }
     }
     return(true);
 }