Skip to content
Snippets Groups Projects
Commit ec2ec9b2 authored by Aaron's avatar Aaron
Browse files

Updated gzip detection. Weaker, but necessary for FIFO support

parent 12fc63b3
No related branches found
No related tags found
No related merge requests found
......@@ -135,13 +135,10 @@ void BedFile::Open(void) {
else {
_bedStream = new ifstream(bedFile.c_str(), ios::in);
//if (isGzipFile(_bedStream) == true) {
if(bedFile.substr(bedFile.find_last_of(".") + 1) == "gz") {
delete _bedStream;
_bedStream = new igzstream(bedFile.c_str(), ios::in);
}
// can we open the file?
if ( !(_bedStream->good()) ) {
cerr << "Error: The requested bed file (" << bedFile << ") could not be opened. Exiting!" << endl;
exit (1);
......
......@@ -40,22 +40,25 @@ returns TRUE if the file has a GZIP header.
Should only be run on regular files.
*/
bool isGzipFile(istream *file) {
//see http://www.gzip.org/zlib/rfc-gzip.html#file-format
//see http://www.gzip.org/zlib/rfc-gzip.html#file-format
struct {
unsigned char id1;
unsigned char id2;
unsigned char cm;
// unsigned char id2;
// unsigned char cm;
} gzip_header;
if (!file->read((char*)&gzip_header, sizeof(gzip_header)))
if (!file->read((char*)&gzip_header, sizeof(gzip_header))) {
return false;
}
if ( gzip_header.id1 == 0x1f
&&
gzip_header.id2 == 0x8b
&&
gzip_header.cm == 8 )
if ( gzip_header.id1 == 0x1f )
// &&
// gzip_header.id2 == 0x8b
// &&
// gzip_header.cm == 8 )
{
return true;
}
file->putback(gzip_header.id1);
return false;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment