diff --git a/gzip.cpp b/gzip.cpp index 04568386..601e5420 100644 --- a/gzip.cpp +++ b/gzip.cpp @@ -63,15 +63,19 @@ void Gunzip::ProcessPrestreamHeader() if (m_inQueue.Skip(length)!=length) throw HeaderErr(); } - if (flags & FILENAME) // skip filename - do + m_filename.clear(); + if (flags & FILENAME) // read filename + do { if(!m_inQueue.Get(b)) throw HeaderErr(); - while (b); + if (b) m_filename += char(b); + } while (b); - if (flags & COMMENTS) // skip comments - do + m_comment.clear(); + if (flags & COMMENTS) // read comments + do { if(!m_inQueue.Get(b)) throw HeaderErr(); - while (b); + if (b) m_comment += char(b); + } while (b); } void Gunzip::ProcessDecompressedData(const byte *inString, size_t length) diff --git a/gzip.h b/gzip.h index a53a23e4..a7efa2ce 100644 --- a/gzip.h +++ b/gzip.h @@ -73,6 +73,9 @@ public: //! \param autoSignalPropagation 0 to turn off MessageEnd signal Gunzip(BufferedTransformation *attachment = NULLPTR, bool repeat = false, int autoSignalPropagation = -1); + const std::string& GetFilename() const { return m_filename; } + const std::string& GetComment() const { return m_comment; } + protected: enum { //! \brief First header magic value @@ -94,6 +97,8 @@ protected: word32 m_length; CRC32 m_crc; + std::string m_filename; + std::string m_comment; }; NAMESPACE_END