| 8 | namespace elz |
| 9 | { |
| 10 | void extractZip(std::string zipname, std::string target) |
| 11 | { |
| 12 | ziputils::unzipper zipFile; |
| 13 | zipFile.open(zipname.c_str()); |
| 14 | for (std::string filename : zipFile.getFilenames()) |
| 15 | { |
| 16 | std::filesystem::path cDir(target + ((std::filesystem::path(filename).parent_path().string() == "") ? "" : "/") + std::filesystem::path(filename).parent_path().string()); |
| 17 | std::filesystem::path cFile(target + "/" + filename); |
| 18 | std::filesystem::path fillPath; |
| 19 | for (std::filesystem::path pathPart : cDir) |
| 20 | { |
| 21 | fillPath /= pathPart; |
| 22 | if (!exists(fillPath)) |
| 23 | { |
| 24 | create_directory(fillPath); |
| 25 | } |
| 26 | } |
| 27 | std::cout << "Opening file : " << filename << std::endl; |
| 28 | zipFile.openEntry(filename.c_str()); |
| 29 | std::ofstream wFile; |
| 30 | wFile.open(cFile.string(), std::ios_base::binary | std::ios_base::out); |
| 31 | std::string dumped = zipFile.dump(); |
| 32 | wFile.write(dumped.c_str(), dumped.size()); |
| 33 | wFile.close(); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | void extractFile(std::string zipname, std::string filename, std::string target) |
| 38 | { |