From d8d0325394d9e5601260fea0433a8b67fd7e6cb8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 31 Jul 2018 11:51:23 -0700 Subject: Remove member function from CentralFileHeader I could have placed the class in an unnamed namespace. That would mark the member function as a local symbol too. But I preferred to move outside so I could make it static. Change-Id: Ie01831ddac5446fdbdeefffd154688c0883ed653 Reviewed-by: Edward Welbourne --- src/gui/text/qzip.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/gui/text') diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index b68c36fd9e..fc7fbcac12 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -391,7 +391,6 @@ struct CentralFileHeader uchar internal_file_attributes[2]; uchar external_file_attributes[4]; uchar offset_local_header[4]; - LocalFileHeader toLocalHeader() const; }; Q_DECLARE_TYPEINFO(CentralFileHeader, Q_PRIMITIVE_TYPE); @@ -541,19 +540,19 @@ public: void addEntry(EntryType type, const QString &fileName, const QByteArray &contents); }; -LocalFileHeader CentralFileHeader::toLocalHeader() const +static LocalFileHeader toLocalHeader(const CentralFileHeader &ch) { LocalFileHeader h; writeUInt(h.signature, 0x04034b50); - copyUShort(h.version_needed, version_needed); - copyUShort(h.general_purpose_bits, general_purpose_bits); - copyUShort(h.compression_method, compression_method); - copyUInt(h.last_mod_file, last_mod_file); - copyUInt(h.crc_32, crc_32); - copyUInt(h.compressed_size, compressed_size); - copyUInt(h.uncompressed_size, uncompressed_size); - copyUShort(h.file_name_length, file_name_length); - copyUShort(h.extra_field_length, extra_field_length); + copyUShort(h.version_needed, ch.version_needed); + copyUShort(h.general_purpose_bits, ch.general_purpose_bits); + copyUShort(h.compression_method, ch.compression_method); + copyUInt(h.last_mod_file, ch.last_mod_file); + copyUInt(h.crc_32, ch.crc_32); + copyUInt(h.compressed_size, ch.compressed_size); + copyUInt(h.uncompressed_size, ch.uncompressed_size); + copyUShort(h.file_name_length, ch.file_name_length); + copyUShort(h.extra_field_length, ch.extra_field_length); return h; } @@ -751,7 +750,7 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const fileHeaders.append(header); - LocalFileHeader h = header.h.toLocalHeader(); + LocalFileHeader h = toLocalHeader(header.h); device->write((const char *)&h, sizeof(LocalFileHeader)); device->write(header.file_name); device->write(data); -- cgit v1.2.3