CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #define SET_BINARY_MODE(file)
23 
24 #define CHUNK 16384
25 
26 namespace spu {
27 
28  // functions for inflating (and deflating) -> (un)zipping the Sherpacks (taken from zlib and zpipe.c)
29  int def(FILE*, FILE*, int);
30  int inf(FILE*, FILE*);
31  void zerr(int);
33 
34  // functions for untaring Sherpacks, based on
35  // http://www.opensource.apple.com/source/libarchive/libarchive-23/libarchive/contrib/untar.c
36  // ...but heavily modified for long path names...
37  /* Parse an octal number, ignoring leading and trailing nonsense. */
38  int parseoct(const char*, size_t);
39  /* Returns true if this is 512 zero bytes. */
40  int is_end_of_archive(const char*);
41  /* Create a directory, including parent directories as necessary. */
42  void create_dir(char*, int);
43  /* Create a file, including parent directory as necessary. */
44  FILE* create_file(char*, int);
45  /* Verify the tar checksum. */
46  int verify_checksum(const char*);
47  /* Extract a tar archive. */
48  void Untar(FILE*, const char*);
49 
50  // function for calculating the MD5 checksum of a file
51  void md5_File(std::string, char*);
52 
53 } // End namespace spu
54 #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)