2012-11-20 08:24:47 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
using std::string;
|
2012-11-15 14:06:22 +00:00
|
|
|
|
2012-11-15 14:51:53 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "boinc_win.h"
|
2012-11-20 08:24:47 +00:00
|
|
|
#else
|
|
|
|
#include <stdlib.h>
|
2012-11-15 14:06:22 +00:00
|
|
|
#endif
|
|
|
|
|
2012-11-20 08:24:47 +00:00
|
|
|
#include "boinc_zip.h"
|
2012-11-15 14:06:22 +00:00
|
|
|
|
2012-11-20 08:24:47 +00:00
|
|
|
int main() {
|
|
|
|
int retval = -2;
|
2012-11-15 14:06:22 +00:00
|
|
|
ZipFileList zf;
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2012-11-20 08:24:47 +00:00
|
|
|
// 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());
|
2012-11-15 14:51:53 +00:00
|
|
|
}
|
2012-11-15 14:06:22 +00:00
|
|
|
#else
|
2012-11-20 08:24:47 +00:00
|
|
|
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());
|
2012-11-15 14:06:22 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|