Lecrapouille / zipper

[Lib][Version 2.1.0][Functional] C++ wrapper around minizip compression library
MIT License
65 stars 13 forks source link

0 sized files extracted as directories. #5

Closed fbergmann closed 1 year ago

fbergmann commented 1 year ago

When zipper extracts an archive containing files of size 0, they will be extracted as directories rather than 0 sized files. This was first filed here:

https://github.com/sbmlteam/libCombine/issues/59

where there is also a test archive showing the issue.

While the zipper version we use is quite old, the issue persists in the current code base, where in:

https://github.com/Lecrapouille/zipper/blob/master/src/Unzipper.cpp#L210

we have:

      if (!entryinfo.uncompressedSize)
        {
            if (!Path::createDir(fileName))
            {
                std::stringstream str;
                str << "Error cannot create folder '" << fileName << "'";
                m_error_code = make_error_code(
                    unzipper_error::INTERNAL_ERROR, str.str());
                err = UNZ_ERRNO;
            }
        }
Lecrapouille commented 1 year ago

@fbergmann Welcome back from other repo ^^ I'll check that

Lecrapouille commented 1 year ago

@fbergmann done. Reopen this ticket if your find other cases

fbergmann commented 1 year ago

I fixed it similarly in the old fork:

https://github.com/fbergmann/zipper/commit/c56a27fa282b7f353b498d60eee636793342b8bb

Lecrapouille commented 1 year ago

@fbergmann I saw it and that what I saw Java people also did. I dunno why they just check the last '/' (Unix) char but not for '\' (Win) and your/their/mine code may be not robust to 'escaped' backslash (while Unix does not like creating file with '/' char). Zip documentation is poor.