Sygmei / 11Zip

Dead simple zipping / unzipping C++ Lib
MIT License
92 stars 22 forks source link

extractZip causing runtime error #6

Closed minorsecond closed 3 years ago

minorsecond commented 3 years ago

Hello,

I'm attempting to extract a zip file using this method:

void UtilityFunctions::unzip_file(const std::string path, const std::string job_num) {
    /*
     * Unzip the zip file located at path.
     * @param path: The path to the zip file
     */

    const std::string target {get_home_path() + "\\Downloads\\tmp"};
    std::cout << "Extracting " << path << " to " << target << std::endl;
    elz::extractZip(path, target);
}

Here's some console output:

Extracting C:\Users\rwardrup\Downloads\5284174 COMSOF Export_.zip to C:\Users\rwardrup\Downloads\tmp
terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'
  what():  filesystem error: cannot create directory: File exists [C:]

However, my program crashes at the extractZip step. I've verified the zip file, but I can't figure it out. Is this the correct implementation?

minorsecond commented 3 years ago

I inserted a print statement just before your second loop in elzip.cpp:

            for (std::filesystem::path pathPart : cDir)
            {
                std::cout << pathPart.string() << std::endl;

and it dies after C:. It looks like it's trying to create the C: directory.

Sygmei commented 3 years ago

Good catch, this should be fixed in this commit : https://github.com/Sygmei/11Zip/commit/cd2bd077d4f4251a68085add332bad3d6b623464 Let me know if something is not working :)

Sygmei commented 3 years ago

I'm closing this issue, feel free to reopen it if this is not working