Lines Matching defs:zip

25 #include "contrib/minizip/zip.h"
81 // Function to add a file to zip
82 bool MockFile::AddFileToZip(zipFile zip, const std::string& filePath, const std::string& entryName)
84 if (zipOpenNewFileInZip(zip, entryName.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED,
86 std::cerr << "Failed to create entry in zip file for " << filePath << std::endl;
93 zipCloseFileInZip(zip);
101 if (zipWriteInFileInZip(zip, buffer, size) < 0) {
102 std::cerr << "Failed to write to zip for " << filePath << std::endl;
108 zipCloseFileInZip(zip);
118 zipCloseFileInZip(zip);
123 // Function to add a folder and its contents recursively to zip
124 bool MockFile::AddFolderToZip(zipFile zip, const std::string& folderPath, const std::string& entryName)
131 if (zipOpenNewFileInZip(zip, (entryName + "/" + relativePath + "/").c_str(), NULL, NULL, 0,
133 std::cerr << "Failed to create entry in zip file for " << entry.path() << std::endl;
136 zipCloseFileInZip(zip);
139 if (!AddFileToZip(zip, entry.path().string(), entryName + "/" + relativePath)) {
151 zipFile zip = zipOpen(zipFilename.c_str(), APPEND_STATUS_CREATE);
152 if (!zip) {
153 std::cerr << "Could not create zip file " << zipFilename << std::endl;
160 if (!AddFolderToZip(zip, file, fs::path(file).filename())) {
161 zipClose(zip, NULL);
166 if (!AddFileToZip(zip, file, fs::path(file).filename())) {
167 zipClose(zip, NULL);
173 if (zipClose(zip, NULL) != ZIP_OK) {
174 std::cerr << "Failed to close zip file " << zipFilename << std::endl;
218 std::string zipFilename = hspFileName + ".zip";