Gunzip: added GetFilename() and GetComment() methods

pull/418/head
Dmitry S. Baikov 2017-05-11 09:29:35 +03:00
parent 3f9667f3cd
commit 3d8e3683db
2 changed files with 15 additions and 6 deletions

View File

@ -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)

5
gzip.h
View File

@ -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