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 #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
spu::is_end_of_archive
int is_end_of_archive(const char *)
Definition: SherpackUtilities.cc:203
spu
Definition: SherpackUtilities.h:26
spu::md5_File
void md5_File(std::string, char *)
Definition: SherpackUtilities.cc:486
spu::inf
int inf(FILE *, FILE *)
Definition: SherpackUtilities.cc:69
spu::create_file
FILE * create_file(char *, int)
Definition: SherpackUtilities.cc:238
spu::Unzip
int Unzip(std::string, std::string)
Definition: SherpackUtilities.cc:153
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
spu::create_dir
void create_dir(char *, int)
Definition: SherpackUtilities.cc:212
spu::Untar
void Untar(FILE *, const char *)
Definition: SherpackUtilities.cc:268
spu::verify_checksum
int verify_checksum(const char *)
Definition: SherpackUtilities.cc:255
spu::def
int def(FILE *, FILE *, int)
Definition: SherpackUtilities.cc:14
spu::parseoct
int parseoct(const char *, size_t)
Definition: SherpackUtilities.cc:186
spu::zerr
void zerr(int)
Definition: SherpackUtilities.cc:129