I'm tring create zip file with libzip library.
list<string> ListOfFiles;
ListOfFiles.push_back("file1");
ListOfFiles.push_back("file2");
ListOfFiles.push_back("file3");
...
createZip(const char* destination)
{
int err;
zip *archive = zip_open(destination, ZIP_CREATE, &err);
cout << "1. " << zip_strerror(archive) << endl;
for (list<string>::iterator iter = ListOfFiles.begin(), end = ListOfFiles.end(); iter != end; iter++)
{
zip_source *source = zip_source_file(archive,iter->c_str(),0,0);
cout << "2. " << zip_strerror(archive) << endl;
index = zip_file_add(archive, iter->c_str(), source, ZIP_FL_OVERWRITE);
cout << "3. " << zip_strerror(archive) << endl;
}
zip_close(archive);
cout << "4. " << zip_strerror(archive) << endl;
}
output:
No error
No error
Invalid argument ...
Read error: No such file or directory
When I tried create zip, error value return "Invalid argument" after i tried added file to zip.