~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to zip/boinc_zip.h

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// this is the "wrapper" header file for the zip/unzip functions to expose to BOINC clients
2
 
// CMC - 18/03/2004, Oxford University for BOINC project
3
 
// released under the BOINC license
4
 
 
5
 
// note that I've disabled zip encryption to try and simplify things
6
 
// (zip encryption is fairly weak and easy to break anyway)
7
 
 
8
 
// you will need to link against the library (boinc_zip.lib on Windows-Release,
9
 
// boinc_zipd.lib for Windows-Debug, or libboinc_zip.a on Unix & Mac OSX)
10
 
 
11
 
// also you will need to include filesys.C in your project
12
 
// (decided not to add that in the lib due to version problems that may arise)
13
 
 
14
 
#ifdef __cplusplus
15
 
#include <vector>
16
 
#include <string>
17
 
#endif
18
 
#include <sys/types.h>
19
 
#include <sys/stat.h>
20
 
 
21
 
#define ZIP_IT   1
22
 
#define UNZIP_IT 0
23
 
 
24
 
// bitmasks for sort type on the ZipFileList 
25
 
// optional but CPDN SmallExecs likes reverse date order
26
 
#define SORT_ASCENDING    0x01
27
 
#define SORT_DESCENDING   0x02
28
 
 
29
 
#define SORT_TIME         0x10
30
 
#define SORT_NAME         0x20
31
 
 
32
 
#ifdef __cplusplus
33
 
using std::string;
34
 
 
35
 
typedef std::vector<std::string> ZipFileList;
36
 
 
37
 
// forward declarations for boinc_zip functions
38
 
// note it's basically like running zip/unzip, just comprise an argc/argv
39
 
// send in an input file or path wildcard, output filename, and basic options
40
 
 
41
 
// default options for zip (bZip = true) are "-j9q" which is 
42
 
// DON'T recurse/list subdirectories, best compression, quiet operation
43
 
// call it with bZiptype = ZIP_IP to zip, bZip = UNZIP_IT to unzip (duh)
44
 
 
45
 
// note boinc_zip is overloaded for ease of use
46
 
// i.e. you can just send char filenames, or std::strings, or preferably
47
 
// a vector of std::string of filenames to add to the zip archive
48
 
 
49
 
// there is also a crude but handy wildcard matching function to build
50
 
// the vector of string's, and probably better than using wildcards in zip
51
 
// across platforms
52
 
 
53
 
bool boinc_filelist(const std::string directory,
54
 
                  const std::string pattern,
55
 
                  ZipFileList* pList, 
56
 
                                  const unsigned char ucSort = SORT_NAME | SORT_DESCENDING,
57
 
                                  const bool bClear = true);
58
 
int boinc_zip(int bZipType, const std::string szFileZip, const ZipFileList* pvectszFileIn);
59
 
int boinc_zip(int bZipType, const std::string szFileZip, const std::string szFileIn);
60
 
 
61
 
int boinc_UnzipToMemory ( char *zip, char *file, std::string &retstr );
62
 
extern "C"
63
 
#else
64
 
extern
65
 
#endif
66
 
int boinc_zip(int bZipType, const char* szFileZip, const char* szFileIn);
67