CMS 3D CMS Logo

SherpackUtilities.h
Go to the documentation of this file.
1 #ifndef SherpackUtilities_h
2 #define SherpackUtilities_h
3 
4 /* Based on the zlib example code zpipe.c
5  * Modified for the use of unzipping Sherpacks
6  * Sebastian Thüer, Markus Merschmeyer
7  * III. Phys. Inst. A, RWTH Aachen University
8  * version 1.0, 1st August 2012
9 */
10 
11 #include <cstdlib>
12 #include <cstdio>
13 #include <string>
14 #include <cstring>
15 #include <cassert>
16 #include <zlib.h>
17 /* This is for mkdir(); this may need to be changed for some platforms. */
18 #include <sys/stat.h> /* For mkdir() */
19 #include <openssl/md5.h>
20 #include <fcntl.h>
21 
22 
23 
24 #define SET_BINARY_MODE(file)
25 
26 #define CHUNK 16384
27 
28 
29 namespace spu {
30 
31 // functions for inflating (and deflating) -> (un)zipping the Sherpacks (taken from zlib and zpipe.c)
32 int def(FILE*, FILE*, int);
33 int inf(FILE*, FILE*);
34 void zerr(int);
36 
37 // functions for untaring Sherpacks, based on
38 // http://www.opensource.apple.com/source/libarchive/libarchive-23/libarchive/contrib/untar.c
39 // ...but heavily modified for long path names...
40 /* Parse an octal number, ignoring leading and trailing nonsense. */
41 int parseoct(const char*, size_t);
42 /* Returns true if this is 512 zero bytes. */
43 int is_end_of_archive(const char*);
44 /* Create a directory, including parent directories as necessary. */
45 void create_dir(char*, int);
46 /* Create a file, including parent directory as necessary. */
47 FILE* create_file(char*, int);
48 /* Verify the tar checksum. */
49 int verify_checksum(const char*);
50 /* Extract a tar archive. */
51 void Untar(FILE*, const char*);
52 
53 // function for calculating the MD5 checksum of a file
54 void md5_File(std::string, char*);
55 
56 
57 } // End namespace spu
58 #endif
int def(FILE *, FILE *, int)
void zerr(int)
void md5_File(std::string, char *)
FILE * create_file(char *, int)
int verify_checksum(const char *)
void Untar(FILE *, const char *)
int is_end_of_archive(const char *)
int inf(FILE *, FILE *)
void create_dir(char *, int)
int parseoct(const char *, size_t)
int Unzip(std::string, std::string)