int main() { int retval = -2; ZipFileList zf; #ifdef _WIN32 // replace with the path/file wildcard of your choice string home = string("C:/Documents and Settings/All Users/Documents"); string result_dir = home + string("/testresult"); CreateDirectoryA(result_dir.c_str(), NULL); string zipfile = result_dir + string("/test.zip"); string source_dir = home + string("/Testfiles"); if (boinc_filelist(source_dir.c_str(), ".txt", &zf) && zf.size()) { retval = boinc_zip(ZIP_IT, zipfile, &zf); retval = boinc_zip(UNZIP_IT, zipfile, result_dir.c_str()); } #else string home = string(getenv("HOME")); string result_dir = home + string("/testresult"); if (mkdir(result_dir.c_str(), 0777) < 0) { perror("mkdir"); } string zipfile = result_dir + string("/test.zip"); string source_dir = home + string("/Testfiles"); if (boinc_filelist(source_dir, string(".txt"), &zf) && zf.size()) { retval = boinc_zip(ZIP_IT, zipfile, &zf); retval = boinc_zip(UNZIP_IT, zipfile, result_dir.c_str()); } #endif return retval; }
int boinc_zip( int bZipType, const std::string szFileZip, const std::string szFileIn ) { ZipFileList tempvec; tempvec.push_back(szFileIn); return boinc_zip(bZipType, szFileZip, &tempvec); }
// same, but with char[] instead of string // int boinc_zip(int bZipType, const char* szFileZip, const char* szFileIn) { string strFileZip, strFileIn; strFileZip.assign(szFileZip); strFileIn.assign(szFileIn); ZipFileList tempvec; tempvec.push_back(strFileIn); return boinc_zip(bZipType, strFileZip, &tempvec); }
int main() { int retval = -2; ZipFileList zf; #ifdef _WIN32 // replace with the path/file wildcard of your choice int retval = boinc_zip(ZIP_IT, "e:\\temp\\netsup.vxd e:\\temp\\vredir.vxd", "e:\\temp\\test.zip", NULL); retval = boinc_zip(UNZIP_IT, "e:\\temp\\test.zip", "/home/carlc/testing", NULL); #else std::string zipfile = "test.zip"; if (boinc_filelist("/var/home/carlc/", ".txt", &zf) && zf.size()) { retval = boinc_zip(ZIP_IT, zipfile, &zf); retval = boinc_zip(UNZIP_IT, zipfile, NULL); } #endif return retval; }
int main(int argc, char* argv[]) { ZipFileList zflist; #ifdef _WIN32 boinc_filelist("c:\\temp", "", &zflist, SORT_NAME | SORT_ASCENDING); #else boinc_filelist("/tmp/junk", "", &zflist, SORT_NAME | SORT_ASCENDING); #endif int jj; char strTmp[128], strTmp2[128]; for (jj = 0; jj < zflist.size(); jj++) { printf("%s %d\n", zflist[jj].c_str(), zflist[jj].m_statFile.st_mtime); // now gzip it, silly but see how it goes! sprintf(strTmp, "%s.gz", zflist[jj].c_str()); sprintf(strTmp2, "%s.zip", strTmp); printf("infile=%s outfile=%s\n", strTmp, strTmp2); do_gzip(strTmp, zflist[jj].c_str()); boinc_zip(ZIP_IT, strTmp2, strTmp); } boinc_zip(UNZIP_IT, "/tmp/boinc_zip.zip", "/tmp/junk/boinc_zip"); return 0; }
// get the list of output files to zip // void get_zip_inputs(ZipFileList &files) { vector<string> initial_files; char fname[256]; read_initial_file_list(initial_files); DIRREF d = dir_open("."); while (!dir_scan(fname, d, sizeof(fname))) { string filename = string(fname); if (in_vector(filename, initial_files)) continue; for (unsigned int i=0; i<zip_patterns.size(); i++) { regmatch match; if (re_exec_w(zip_patterns[i], fname, 1, &match) == 1) { files.push_back(filename); break; } } } }