Ejemplo n.º 1
0
    void bunzip2OstreamTest()
    {
        // test
        std::stringstream bzip2target;

        {
            zim::Bzip2Stream compressor(bzip2target);
            compressor << testtext << std::flush;
            compressor.end();
        }

        {
            std::ostringstream msg;
            msg << "teststring with " << testtext.size() << " bytes compressed into " << bzip2target.str().size() << " bytes";
            reportMessage(msg.str());
        }

        std::ostringstream bunzip2target;

        {
            zim::Bunzip2Stream bunzip2(bunzip2target); // bunzip2 is a ostream here
            bunzip2 << bzip2target.str() << std::flush;
        }

        {
            std::ostringstream msg;
            msg << "teststring uncompressed to " << bunzip2target.str().size() << " bytes";
            reportMessage(msg.str());
        }

        CXXTOOLS_UNIT_ASSERT_EQUALS(testtext, bunzip2target.str());
    }
Ejemplo n.º 2
0
QByteArray ArchiveReader::unpack(const QString &path)
{
    QString lPath = path.toLower();
    if (path.endsWith(".mdz") ||
            lPath.endsWith(".s3z") ||
            lPath.endsWith(".xmz") ||
            lPath.endsWith(".itz"))
        return unzip(path);
    else if (lPath.endsWith(".mdgz") ||
             lPath.endsWith(".s3gz") ||
             lPath.endsWith(".xmgz") ||
             lPath.endsWith(".itgz"))
        return gunzip(path);
    else if (lPath.endsWith(".mdbz"))
        return bunzip2(path);

    return QByteArray();
}
Ejemplo n.º 3
0
int __init decompress(void *inbuf, unsigned int len, void *outbuf)
{
#if 0 /* Not needed here yet. */
    if ( len >= 2 &&
         (!memcmp(inbuf, "\037\213", 2) || !memcmp(inbuf, "\037\236", 2)) )
        return gunzip(inbuf, len, NULL, NULL, outbuf, NULL, error);
#endif

    if ( len >= 3 && !memcmp(inbuf, "\x42\x5a\x68", 3) )
        return bunzip2(inbuf, len, NULL, NULL, outbuf, NULL, error);

    if ( len >= 2 && !memcmp(inbuf, "\135\000", 2) )
        return unlzma(inbuf, len, NULL, NULL, outbuf, NULL, error);

    if ( len >= 5 && !memcmp(inbuf, "\x89LZO", 5) )
        return unlzo(inbuf, len, NULL, NULL, outbuf, NULL, error);

    return 1;
}