Example #1
0
        /// <summary>
        /// This function is called from the Parse routine. The purpose of this exercise , is to figure out the escape
        /// values in the regular 32 bit EOCD. We shouldn't be using values from the 64 bit structure if it wasn't
        /// escaped in the 32 bit structure.
        /// </summary>
        private void OverrideValuesBasedOnEndOfCentralDirectory(ZipIOEndOfCentralDirectoryBlock zipIoEocd)
        {
            // 16 bit numbers
            if (zipIoEocd.NumberOfThisDisk < UInt16.MaxValue)
            {
                _numberOfThisDisk = zipIoEocd.NumberOfThisDisk;
            }

            if (zipIoEocd.NumberOfTheDiskWithTheStartOfTheCentralDirectory < UInt16.MaxValue)
            {
                _numberOfTheDiskWithTheStartOfTheCentralDirectory = zipIoEocd.NumberOfTheDiskWithTheStartOfTheCentralDirectory;
            }

            if (zipIoEocd.TotalNumberOfEntriesInTheCentralDirectoryOnThisDisk < UInt16.MaxValue)
            {
                _totalNumberOfEntriesInTheCentralDirectoryOnThisDisk = zipIoEocd.TotalNumberOfEntriesInTheCentralDirectoryOnThisDisk;
            }

            if (zipIoEocd.TotalNumberOfEntriesInTheCentralDirectory < UInt16.MaxValue)
            {
                _totalNumberOfEntriesInTheCentralDirectory = zipIoEocd.TotalNumberOfEntriesInTheCentralDirectory;
            }

            // 32  bit numbers
            if (zipIoEocd.SizeOfTheCentralDirectory < UInt32.MaxValue)
            {
                _sizeOfTheCentralDirectory = zipIoEocd.SizeOfTheCentralDirectory;
            }

            if (zipIoEocd.OffsetOfStartOfCentralDirectory < UInt32.MaxValue)
            {
                _offsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber = zipIoEocd.OffsetOfStartOfCentralDirectory;
            }
        }
Example #2
0
 /// <summary>
 /// This function is called from the Create New routine. The purpose of this exercise , is to copy data from 32 bit EOCD into this record,
 /// for scenarios when ZIP64 EOCD wasn't parsed from a file, but was just made up.
 /// This is done so that Central Dir parsing code can ask the ZIP64 EOCD for this data, and regardless of whether it is real zip 64 file or
 /// not a zip 64 file it will get the right CD offset , size and so on
 /// </summary>
 private void InitializeFromEndOfCentralDirectory(ZipIOEndOfCentralDirectoryBlock zipIoEocd)
 {
     _numberOfThisDisk = zipIoEocd.NumberOfThisDisk;
     _numberOfTheDiskWithTheStartOfTheCentralDirectory    = zipIoEocd.NumberOfTheDiskWithTheStartOfTheCentralDirectory;
     _totalNumberOfEntriesInTheCentralDirectoryOnThisDisk = zipIoEocd.TotalNumberOfEntriesInTheCentralDirectoryOnThisDisk;
     _totalNumberOfEntriesInTheCentralDirectory           = zipIoEocd.TotalNumberOfEntriesInTheCentralDirectory;
     _sizeOfTheCentralDirectory = zipIoEocd.SizeOfTheCentralDirectory;
     _offsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber = zipIoEocd.OffsetOfStartOfCentralDirectory;
 }
        internal static ZipIOEndOfCentralDirectoryBlock CreateNew(ZipIOBlockManager blockManager, long offset)
        {
            ZipIOEndOfCentralDirectoryBlock block = new ZipIOEndOfCentralDirectoryBlock(blockManager);

            block._offset    = offset;
            block._dirtyFlag = true;

            return(block);
        }
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------
        internal static ZipIOEndOfCentralDirectoryBlock SeekableLoad(ZipIOBlockManager blockManager)
        {
            // perform custom serach for record
            long blockPosition = FindPosition(blockManager.Stream);

            blockManager.Stream.Seek(blockPosition, SeekOrigin.Begin);

            ZipIOEndOfCentralDirectoryBlock block = new ZipIOEndOfCentralDirectoryBlock(blockManager);

            block.ParseRecord(blockManager.BinaryReader, blockPosition);
            return(block);
        }
        /// <summary>
        /// This function is called from the Parse routine. The purpose of this exercise , is to figure out the escape
        /// values in the regular 32 bit EOCD. We shouldn't be using values from the 64 bit structure if it wasn't
        /// escaped in the 32 bit structure. 
        /// </summary>
        private void OverrideValuesBasedOnEndOfCentralDirectory(ZipIOEndOfCentralDirectoryBlock zipIoEocd) 
        { 
            // 16 bit numbers
            if (zipIoEocd.NumberOfThisDisk < UInt16.MaxValue) 
                {_numberOfThisDisk = zipIoEocd.NumberOfThisDisk;}

            if (zipIoEocd.NumberOfTheDiskWithTheStartOfTheCentralDirectory < UInt16.MaxValue)
                {_numberOfTheDiskWithTheStartOfTheCentralDirectory = zipIoEocd.NumberOfTheDiskWithTheStartOfTheCentralDirectory;} 

            if (zipIoEocd.TotalNumberOfEntriesInTheCentralDirectoryOnThisDisk  < UInt16.MaxValue) 
                {_totalNumberOfEntriesInTheCentralDirectoryOnThisDisk  = zipIoEocd.TotalNumberOfEntriesInTheCentralDirectoryOnThisDisk;} 

            if (zipIoEocd.TotalNumberOfEntriesInTheCentralDirectory < UInt16.MaxValue) 
                {_totalNumberOfEntriesInTheCentralDirectory = zipIoEocd.TotalNumberOfEntriesInTheCentralDirectory;}

            // 32  bit numbers
            if (zipIoEocd.SizeOfTheCentralDirectory < UInt32.MaxValue) 
                {_sizeOfTheCentralDirectory = zipIoEocd.SizeOfTheCentralDirectory;}
 
            if (zipIoEocd.OffsetOfStartOfCentralDirectory < UInt32.MaxValue) 
                {_offsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber = zipIoEocd.OffsetOfStartOfCentralDirectory;}
 
        }
 /// <summary>
 /// This function is called from the Create New routine. The purpose of this exercise , is to copy data from 32 bit EOCD into this record, 
 /// for scenarios when ZIP64 EOCD wasn't parsed from a file, but was just made up.
 /// This is done so that Central Dir parsing code can ask the ZIP64 EOCD for this data, and regardless of whether it is real zip 64 file or 
 /// not a zip 64 file it will get the right CD offset , size and so on 
 /// </summary>
 private void InitializeFromEndOfCentralDirectory(ZipIOEndOfCentralDirectoryBlock zipIoEocd) 
 {
     _numberOfThisDisk = zipIoEocd.NumberOfThisDisk;
     _numberOfTheDiskWithTheStartOfTheCentralDirectory = zipIoEocd.NumberOfTheDiskWithTheStartOfTheCentralDirectory;
     _totalNumberOfEntriesInTheCentralDirectoryOnThisDisk  = zipIoEocd.TotalNumberOfEntriesInTheCentralDirectoryOnThisDisk; 
     _totalNumberOfEntriesInTheCentralDirectory = zipIoEocd.TotalNumberOfEntriesInTheCentralDirectory;
     _sizeOfTheCentralDirectory = zipIoEocd.SizeOfTheCentralDirectory; 
     _offsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber = zipIoEocd.OffsetOfStartOfCentralDirectory; 
 }
        internal static ZipIOEndOfCentralDirectoryBlock CreateNew(ZipIOBlockManager blockManager, long offset)          
        {
            ZipIOEndOfCentralDirectoryBlock block = new ZipIOEndOfCentralDirectoryBlock(blockManager);

            block._offset = offset;
            block._dirtyFlag = true;

            return block;
        }
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------
        internal static ZipIOEndOfCentralDirectoryBlock SeekableLoad (ZipIOBlockManager blockManager)  
        {
            // perform custom serach for record 
            long blockPosition = FindPosition(blockManager.Stream);
            blockManager.Stream.Seek(blockPosition, SeekOrigin.Begin);

            ZipIOEndOfCentralDirectoryBlock block = new ZipIOEndOfCentralDirectoryBlock(blockManager);
            
            block.ParseRecord(blockManager.BinaryReader, blockPosition);
            return block;
        }