Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:12

0001 #ifndef SherpackUtilities_h
0002 #define SherpackUtilities_h
0003 
0004 /* Based on the zlib example code zpipe.c
0005  * Modified for the use of unzipping Sherpacks
0006  * Sebastian Thüer, Markus Merschmeyer
0007  * III. Phys. Inst. A, RWTH Aachen University
0008  * version 1.0, 1st August 2012
0009 */
0010 
0011 #include <cstdlib>
0012 #include <cstdio>
0013 #include <string>
0014 #include <cstring>
0015 #include <cassert>
0016 #include <zlib.h>
0017 /* This is for mkdir(); this may need to be changed for some platforms. */
0018 #include <sys/stat.h> /* For mkdir() */
0019 #include <openssl/md5.h>
0020 #include <fcntl.h>
0021 
0022 #define SET_BINARY_MODE(file)
0023 
0024 #define CHUNK 16384
0025 
0026 namespace spu {
0027 
0028   // functions for inflating (and deflating) -> (un)zipping the Sherpacks (taken from zlib and zpipe.c)
0029   int def(FILE*, FILE*, int);
0030   int inf(FILE*, FILE*);
0031   void zerr(int);
0032   int Unzip(std::string, std::string);
0033 
0034   // functions for untaring Sherpacks, based on
0035   // http://www.opensource.apple.com/source/libarchive/libarchive-23/libarchive/contrib/untar.c
0036   // ...but heavily modified for long path names...
0037   /* Parse an octal number, ignoring leading and trailing nonsense. */
0038   int parseoct(const char*, size_t);
0039   /* Returns true if this is 512 zero bytes. */
0040   int is_end_of_archive(const char*);
0041   /* Create a directory, including parent directories as necessary. */
0042   void create_dir(char*, int);
0043   /* Create a file, including parent directory as necessary. */
0044   FILE* create_file(char*, int);
0045   /* Verify the tar checksum. */
0046   int verify_checksum(const char*);
0047   /* Extract a tar archive. */
0048   void Untar(FILE*, const char*);
0049 
0050   // function for calculating the MD5 checksum of a file
0051   void md5_File(std::string, char*);
0052 
0053 }  // End namespace spu
0054 #endif