libStatGen Software
1
|
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 #include "UncompressedFileType.h" 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 // Method to read the gzip header from a file of UncompresedFileType. 00036 // Returns true if the file is a gzip file, false, otherwise. 00037 bool readHeader(UncompressedFileType& file); 00038 00039 // Determine if the file is a gzip file. 00040 bool isGzipFile(); 00041 00042 // Determine if the file is a BGZF compressed file. 00043 bool isBgzfFile(); 00044 00045 private: 00046 00047 static const unsigned int GZIP_HEADER_SIZE = 18; 00048 00049 union 00050 { 00051 struct 00052 { 00053 uint8_t id1; 00054 uint8_t id2; 00055 uint8_t cm; 00056 uint8_t flg; 00057 uint32_t mtime; 00058 uint8_t xfl; 00059 uint8_t os; 00060 uint16_t xlen; 00061 uint8_t si1; 00062 uint8_t si2; 00063 uint16_t slen; 00064 uint16_t bsize; 00065 }; 00066 char headerBuffer[GzipHeader::GZIP_HEADER_SIZE]; 00067 }; 00068 char buffer[GZIP_HEADER_SIZE]; 00069 00070 }; 00071 00072 00073 #endif