void ZipArchiveEntry::SerializeLocalFileHeader(std::ostream& stream) { // ensure opening the stream std::istream* compressedDataStream = nullptr; if (!this->IsDirectory()) { if (_inputStream == nullptr) { if (!_isNewOrChanged) { // the file was either compressed in immediate mode, // or was in previous archive compressedDataStream = this->GetRawStream(); } // if file is new and empty or stream has been set to nullptr, // just do not set any compressed data stream } else { assert(_isNewOrChanged); compressedDataStream = _inputStream; } } if (!_hasLocalFileHeader) { this->FetchLocalFileHeader(); } // save offset of stream here _offsetOfSerializedLocalFileHeader = stream.tellp(); if (this->IsUsingDataDescriptor()) { _localFileHeader.CompressedSize = 0; _localFileHeader.UncompressedSize = 0; _localFileHeader.Crc32 = 0; } _localFileHeader.Serialize(stream); // if this entry is a directory, it should not contain any data // nor crc. assert( this->IsDirectory() ? !GetCrc32() && !GetSize() && !GetCompressedSize() && !_inputStream : true ); if (!this->IsDirectory() && compressedDataStream != nullptr) { if (_isNewOrChanged) { this->InternalCompressStream(*compressedDataStream, stream); if (this->IsUsingDataDescriptor()) { _localFileHeader.SerializeAsDataDescriptor(stream); } else { // actualize local file header // make non-seekable version? stream.seekp(_offsetOfSerializedLocalFileHeader); _localFileHeader.Serialize(stream); stream.seekp(this->GetCompressedSize(), std::ios::cur); } } else { utils::stream::copy(*compressedDataStream, stream); } } }
size_t GetCompressedSize(const C& obj, const SSplitterParams& params) { Set(obj, params); return GetCompressedSize(); }
void Set(const C& obj, const SSplitterParams& params) { Set(obj); GetCompressedSize(params); }
size_t CAsnSizer::GetCompressedSize(const SSplitterParams& params) { CId2Compressor::Compress(params, m_CompressedData, GetAsnData(), GetAsnSize()); return GetCompressedSize(); }