WriteBlock() public static méthode

public static WriteBlock ( Stream stream, long numberOfEntries, long startOfCentralDirectory, long sizeOfCentralDirectory ) : void
stream Stream
numberOfEntries long
startOfCentralDirectory long
sizeOfCentralDirectory long
Résultat void
Exemple #1
0
        //writes eocd, and if needed, zip 64 eocd, zip64 eocd locator
        //should only throw an exception in extremely exceptional cases because it is called from dispose
        private void WriteArchiveEpilogue(long startOfCentralDirectory, long sizeOfCentralDirectory)
        {
            //determine if we need Zip 64
            bool needZip64 = false;

            if (startOfCentralDirectory >= uint.MaxValue ||
                sizeOfCentralDirectory >= uint.MaxValue ||
                _entries.Count >= ZipHelper.Mask16Bit
#if DEBUG_FORCE_ZIP64
                || _forceZip64
#endif
                )
            {
                needZip64 = true;
            }

            //if we need zip 64, write zip 64 eocd and locator
            if (needZip64)
            {
                long zip64EOCDRecordStart = _archiveStream.Position;

                Zip64EndOfCentralDirectoryRecord.WriteBlock(_archiveStream, _entries.Count, startOfCentralDirectory, sizeOfCentralDirectory);
                Zip64EndOfCentralDirectoryLocator.WriteBlock(_archiveStream, zip64EOCDRecordStart);
            }

            //write normal eocd
            ZipEndOfCentralDirectoryBlock.WriteBlock(_archiveStream, _entries.Count, startOfCentralDirectory, sizeOfCentralDirectory, _archiveComment);
        }
Exemple #2
0
        private void WriteArchiveEpilogue(long startOfCentralDirectory, long sizeOfCentralDirectory)
        {
            bool flag = false;

            if (startOfCentralDirectory >= (ulong)-1 || sizeOfCentralDirectory >= (ulong)-1 || this._entries.Count >= 65535)
            {
                flag = true;
            }
            if (flag)
            {
                long position = this._archiveStream.Position;
                Zip64EndOfCentralDirectoryRecord.WriteBlock(this._archiveStream, (long)this._entries.Count, startOfCentralDirectory, sizeOfCentralDirectory);
                Zip64EndOfCentralDirectoryLocator.WriteBlock(this._archiveStream, position);
            }
            ZipEndOfCentralDirectoryBlock.WriteBlock(this._archiveStream, (long)this._entries.Count, startOfCentralDirectory, sizeOfCentralDirectory, this._archiveComment);
        }