bool CSimpleZip::Add(std::string strZipFile,std::list<std::string>& lstFile,std::string strRootPath,bool bFullPath) { CZipArchive zip; CZipString szArchive; int iVolumeSize = 0; int iMode = CZipArchive::zipOpen; szArchive =CZipString(strZipFile); if (!ZipPlatform::FileExists(szArchive)) iMode = CZipArchive::zipCreate; CZipPathComponent zpc(szArchive); SpanCallback span; zip.SetSpanCallback(&span); try { zip.Open(szArchive, iMode, iVolumeSize); } catch(...) { return FALSE; } zip.SetRootPath(strRootPath.c_str()); FILELIST lFiles; for(std::list<std::string>::iterator it =lstFile.begin();it!=lstFile.end();it++) { std::string strFileName; strFileName =*it; lFiles.push_back(CZipString(strFileName)); } FILELISTADD rev; for (FILELISTIT it = lFiles.begin(); it != lFiles.end(); ++it) { CZipString sz = zip.PredictFileNameInZip(*it, bFullPath); if (!sz.IsEmpty()) rev.push_back(CZipAddFileInfo(*it, sz)); } lFiles.clear(); // rev.sort(std::greater<CZipAddFileInfo>()); FILELISTADDIT it1; int iSmartLevel = CZipArchive::zipsmSafeSmart; for (it1 = rev.begin(); it1 != rev.end(); ++it1) { if (zip.AddNewFile((*it1).m_szFilePath, 5, bFullPath, iSmartLevel)) { printf ("%s added\n", (LPCTSTR)(*it1).m_szFileNameInZip); } else printf ("%s not added\n", (LPCTSTR)(*it1).m_szFilePath); } zip.Close(); return TRUE; }