@@ -677,6 +677,38 @@ private void ReadEndOfCentralDirectory()
677
677
}
678
678
}
679
679
680
+ private void TryReadZip64EndOfCentralDirectoryPostReadZip64Block ( bool result , Zip64EndOfCentralDirectoryRecord record )
681
+ {
682
+ if ( ! result )
683
+ throw new InvalidDataException ( SR . Zip64EOCDNotWhereExpected ) ;
684
+
685
+ _numberOfThisDisk = record . NumberOfThisDisk ;
686
+
687
+ if ( record . NumberOfEntriesTotal > long . MaxValue )
688
+ throw new InvalidDataException ( SR . FieldTooBigNumEntries ) ;
689
+
690
+ if ( record . OffsetOfCentralDirectory > long . MaxValue )
691
+ throw new InvalidDataException ( SR . FieldTooBigOffsetToCD ) ;
692
+
693
+ if ( record . NumberOfEntriesTotal != record . NumberOfEntriesOnThisDisk )
694
+ throw new InvalidDataException ( SR . SplitSpanned ) ;
695
+
696
+ _expectedNumberOfEntries = ( long ) record . NumberOfEntriesTotal ;
697
+ _centralDirectoryStart = ( long ) record . OffsetOfCentralDirectory ;
698
+ }
699
+
700
+ private void TryReadZip64EndOfCentralDirectoryPostLocateZip64Block ( bool zip64eocdLocatorProper , Zip64EndOfCentralDirectoryLocator locator )
701
+ {
702
+ Debug . Assert ( zip64eocdLocatorProper ) ; // we just found this using the signature finder, so it should be okay
703
+
704
+ if ( locator . OffsetOfZip64EOCD > long . MaxValue )
705
+ throw new InvalidDataException ( SR . FieldTooBigOffsetToZip64EOCD ) ;
706
+
707
+ long zip64EOCDOffset = ( long ) locator . OffsetOfZip64EOCD ;
708
+
709
+ _archiveStream . Seek ( zip64EOCDOffset , SeekOrigin . Begin ) ;
710
+ }
711
+
680
712
// Tries to find the Zip64 End of Central Directory Locator, then the Zip64 End of Central Directory, assuming the
681
713
// End of Central Directory block has already been found, as well as the location in the stream where the EOCD starts.
682
714
private void TryReadZip64EndOfCentralDirectory ( ZipEndOfCentralDirectoryBlock eocd , long eocdStart )
@@ -701,34 +733,10 @@ private void TryReadZip64EndOfCentralDirectory(ZipEndOfCentralDirectoryBlock eoc
701
733
{
702
734
// use locator to get to Zip64-EOCD
703
735
bool zip64eocdLocatorProper = Zip64EndOfCentralDirectoryLocator . TryReadBlock ( _archiveStream , out Zip64EndOfCentralDirectoryLocator locator ) ;
704
- Debug . Assert ( zip64eocdLocatorProper ) ; // we just found this using the signature finder, so it should be okay
705
-
706
- if ( locator . OffsetOfZip64EOCD > long . MaxValue )
707
- throw new InvalidDataException ( SR . FieldTooBigOffsetToZip64EOCD ) ;
708
-
709
- long zip64EOCDOffset = ( long ) locator . OffsetOfZip64EOCD ;
710
-
711
- _archiveStream . Seek ( zip64EOCDOffset , SeekOrigin . Begin ) ;
712
-
736
+ TryReadZip64EndOfCentralDirectoryPostLocateZip64Block ( zip64eocdLocatorProper , locator ) ;
713
737
// Read Zip64 End of Central Directory Record
714
-
715
- Zip64EndOfCentralDirectoryRecord record ;
716
- if ( ! Zip64EndOfCentralDirectoryRecord . TryReadBlock ( _archiveStream , out record ) )
717
- throw new InvalidDataException ( SR . Zip64EOCDNotWhereExpected ) ;
718
-
719
- _numberOfThisDisk = record . NumberOfThisDisk ;
720
-
721
- if ( record . NumberOfEntriesTotal > long . MaxValue )
722
- throw new InvalidDataException ( SR . FieldTooBigNumEntries ) ;
723
-
724
- if ( record . OffsetOfCentralDirectory > long . MaxValue )
725
- throw new InvalidDataException ( SR . FieldTooBigOffsetToCD ) ;
726
-
727
- if ( record . NumberOfEntriesTotal != record . NumberOfEntriesOnThisDisk )
728
- throw new InvalidDataException ( SR . SplitSpanned ) ;
729
-
730
- _expectedNumberOfEntries = ( long ) record . NumberOfEntriesTotal ;
731
- _centralDirectoryStart = ( long ) record . OffsetOfCentralDirectory ;
738
+ bool result = Zip64EndOfCentralDirectoryRecord . TryReadBlock ( _archiveStream , out Zip64EndOfCentralDirectoryRecord record ) ;
739
+ TryReadZip64EndOfCentralDirectoryPostReadZip64Block ( result , record ) ;
732
740
}
733
741
}
734
742
}
0 commit comments