ZLib / Ziputil and MINGW

Started by
0 comments, last by NicoG 15 years, 8 months ago

bool dtZipManager::OpenZip(const char* archive, const char* passwd)
{
    this->CloseZip();

    // Copy stuff
    m_archivename = archive;
    if (!passwd && !m_password.empty())
    {
        m_password.clear();
    }
    else
    {
        m_password = passwd;
    }

    for (u32 i = 0; i < strlen(archive); i++)
    {
        if (m_archivename == dtEvilSep)
        {
            m_archivename = dtPathSep;
        }
    }

    m_zip = unzOpen(m_archivename.c_str());
    if (!m_zip)
    {
        return false;
    }
    return true;
}

dtMemoryHandle* dtZipManager::Decompress(const char* file)
{
    // Return if there is no file open
    if (!m_zip)
    {
        return NULL;
    }

    dtMemoryHandle* handle = NULL;
    unz_file_info file_info;
    int done = 0;
    char current[_MAX_PATH];

    done = unzGoToFirstFile(m_zip);
    while(done == UNZ_OK)
    {
        unzGetCurrentFileInfo(m_zip, &file_info, current, sizeof(current), 0, 0, 0, 0);

        for(int i=0; current; i++)
        {
            if(current== dtEvilSep)
            {
                current= dtPathSep;
            }
        }

        if (CompareFileName(current, file) == true)
        {
            // If no password supplied, this opens the File normally.
            if(unzOpenCurrentFilePassword(m_zip, m_password.empty() ? NULL : m_password.c_str()) == UNZ_OK)
            {
                handle = new dtMemoryHandle(file_info.uncompressed_size);
                assert(handle->data != NULL);

                unzReadCurrentFile(m_zip, handle->data, handle->size);
                assert(handle->data);
                handle->file = file;
                unzCloseCurrentFile(m_zip);

                return handle;
            }
        }

        done=unzGoToNextFile(m_zip);
    }
    return NULL;
}
I use this code to unzip textures (tga) from zips to memory. It works as long as I use MSVC Express 2008 but it fails when I use mingw. With "it fails" I mean that the pictures are black with artifacts or the picture has other distortions. Anyone any clue about this issue? Is my code bad or something in the library? I have recreated the zip with alternative packers, no change. The textures are loaded properly when I load them from the disc, so I assume the problem is here. I am using the ziputil (unzip.h) for zlib and compiled this as static library. The code above is compiled as DLL. However, the user has no interaction with objects from zlib, so this shouldn't be an issue. And as I said, it works under MSCVE. regards
If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/
Advertisement
No clues anyone? :(
Just tell me, if you need more infos..
If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/

This topic is closed to new replies.

Advertisement