GzipHeader.h

00001 /*
00002  *  Copyright (C) 2010  Regents of the University of Michigan
00003  *
00004  *   This program is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef __GZIPHEADER_H__
00019 #define __GZIPHEADER_H__
00020 
00021 #include <stdint.h>
00022 #include <stdio.h>
00023 
00024 
00025 class GzipHeader
00026 {
00027 public:
00028     GzipHeader();
00029     ~GzipHeader();
00030 
00031     // Method to read the gzip header from a file.
00032     // Returns true if the file is a gzip file, false, otherwise.
00033     bool readHeader(FILE* filePtr);
00034 
00035     // Determine if the file is a gzip file.
00036     bool isGzipFile();
00037 
00038     // Determine if the file is a BGZF compressed file.
00039     bool isBgzfFile();
00040 
00041 private:
00042 
00043     static const unsigned int GZIP_HEADER_SIZE = 18;
00044 
00045     union
00046     {
00047         struct
00048         {
00049             uint8_t  id1;
00050             uint8_t  id2;
00051             uint8_t  cm;
00052             uint8_t  flg;
00053             uint32_t mtime;
00054             uint8_t  xfl;
00055             uint8_t  os;
00056             uint16_t xlen;
00057             uint8_t si1;
00058             uint8_t si2;
00059             uint16_t slen;
00060             uint16_t bsize;
00061         };
00062         char headerBuffer[GZIP_HEADER_SIZE];
00063     };
00064     char buffer[GZIP_HEADER_SIZE];
00065 
00066 };
00067 
00068 
00069 #endif
Generated on Wed Nov 17 15:38:28 2010 for StatGen Software by  doxygen 1.6.3