System.IO.Compression.ZipArchive.AcquireArchiveStream C# (CSharp) Method

AcquireArchiveStream() private method

private AcquireArchiveStream ( ZipArchiveEntry entry ) : void
entry ZipArchiveEntry
return void
        internal void AcquireArchiveStream(ZipArchiveEntry entry)
        {
            //if a previous entry had held the stream but never wrote anything, we write their local header for them
            if (_archiveStreamOwner != null)
            {
                if (!_archiveStreamOwner.EverOpenedForWrite)
                {
                    _archiveStreamOwner.WriteAndFinishLocalEntry();
                }
                else
                {
                    throw new IOException(SR.CreateModeCreateEntryWhileOpen);
                }
            }

            _archiveStreamOwner = entry;
        }

Usage Example

Exemplo n.º 1
0
        // Initializes new entry
        internal ZipArchiveEntry(ZipArchive archive, string entryName)
        {
            _archive = archive;

            _originallyInArchive = false;

            _diskNumberStart            = 0;
            _versionMadeByPlatform      = CurrentZipPlatform;
            _versionMadeBySpecification = ZipVersionNeededValues.Default;
            _versionToExtract           = ZipVersionNeededValues.Default; // this must happen before following two assignment
            _generalPurposeBitFlag      = 0;
            CompressionMethod           = CompressionMethodValues.Deflate;
            _lastModified = DateTimeOffset.Now;

            _compressedSize               = 0; // we don't know these yet
            _uncompressedSize             = 0;
            _externalFileAttr             = 0;
            _offsetOfLocalHeader          = 0;
            _storedOffsetOfCompressedData = null;
            _crc32 = 0;

            _compressedBytes        = null;
            _storedUncompressedData = null;
            _currentlyOpenForWrite  = false;
            _everOpenedForWrite     = false;
            _outstandingWriteStream = null;

            FullName = entryName;

            _cdUnknownExtraFields = null;
            _lhUnknownExtraFields = null;
            _fileComment          = null;

            _compressionLevel = null;

            if (_storedEntryNameBytes.Length > ushort.MaxValue)
            {
                throw new ArgumentException();
            }

            // grab the stream if we're in create mode
            if (_archive.Mode == ZipArchiveMode.Create)
            {
                _archive.AcquireArchiveStream(this);
            }
        }
All Usage Examples Of System.IO.Compression.ZipArchive::AcquireArchiveStream