Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

After compress successfully(using Poco lib), I found that I can able to decompress a .zip file which contains files but not sub-folder

My decompress block of code :

struct UnzipStruct unzipObject;
unzipObject.unzip(source, target);

Here is MyUnzipStruct :

struct UnzipStruct
    void unzip(std::string source, std::string target) {
        fs::path sourcePath = fs::path(source);
        std::ifstream inp(sourcePath.string(), ios::binary);
        fs::path targetPath = fs::path(target);
        Poco::Path targetDir(targetPath.string());
        Poco::Zip::Decompress dec(inp, targetDir, false, true);
        // if an error happens invoke the ZipHandlingLib::onDecompressError method
        dec.EError += Poco::Delegate<UnzipStruct, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string>>(this, &UnzipStruct::onDecompressError);
        dec.decompressAllFiles();
        dec.EError -= Poco::Delegate<UnzipStruct, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string>>(this, &UnzipStruct::onDecompressError);
        inp.close();
    void onDecompressError(const void* pSender, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string>& info)
        std::cerr << info.second << "\n";
} unzipObject;

Is it a bug of Poco or Did I do something wrong? Because I can extract a zip file by 7z(which contains sub-folder). The exception I get is AssertionViolationException from Poco.

Look at the example how to set up an error handler for dec.EError pocoproject.org/docs/ZipUserGuide.html – 273K Jan 6, 2020 at 6:12 @S.M. I'm just getting errors near Ziptest, do you know which file to includes or which methods do I need to implement to fix it? – Nguyễn Đức Tâm Jan 6, 2020 at 6:42 ZipTest is just a test class name, you should implement the class ZipTest (or another name) with the method onDecompressError (or another name) and pass object of the class and pointer to the method to the poco::Delegate constructor. – 273K Jan 7, 2020 at 4:11 @S.M. yeah, I just edited my post, I have come through that but still can't extract the zip file yet. – Nguyễn Đức Tâm Jan 7, 2020 at 4:12 I think it's better to report the issue on Poco bug tracker github.com/pocoproject/poco/issues – 273K Jan 7, 2020 at 4:23

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.