Loading...
Searching...
No Matches
GzipHeader Class Reference

## Public Member Functions

bool | readHeader (FILE *filePtr)
bool | readHeader (UncompressedFileType &file)
bool | isGzipFile ()
bool | isBgzfFile ()

## Detailed Description

Definition at line 25 of file GzipHeader.h.

## Constructor & Destructor Documentation

## GzipHeader()

GzipHeader::GzipHeader | ( |  | ) |

Definition at line 24 of file GzipHeader.cpp.

{
// clear the union via memset:
memset(headerBuffer, 0, sizeof(headerBuffer));
}

## ~GzipHeader()

GzipHeader::~GzipHeader | ( |  | ) |

Definition at line 32 of file GzipHeader.cpp.

{
}

## Member Function Documentation

## isBgzfFile()

bool GzipHeader::isBgzfFile | ( |  | ) |

Definition at line 111 of file GzipHeader.cpp.

{
if (isGzipFile() && (si1 == 66) && (si2 == 67))
{
return true;
}
return false;
}

## isGzipFile()

bool GzipHeader::isGzipFile | ( |  | ) |

Definition at line 100 of file GzipHeader.cpp.

{
if ((id1 == 31) && (id2 == 139))
{
return true;
}
return false;
}

## readHeader() [1/2]

bool GzipHeader::readHeader | ( | FILE * | filePtr | ) |

Definition at line 39 of file GzipHeader.cpp.

{
bool isGzip = false;
// If the file is not already open, return false.
if (filePtr == NULL)
{
// File is not open, so return false - not a gzip file.
return(false);
}
// Try to read a header from the file.
// if(144 == fread(buffer, 1, 144, filePtr))
if (GZIP_HEADER_SIZE == fread(buffer, 1, GZIP_HEADER_SIZE, filePtr))
{
memcpy(headerBuffer, buffer, GZIP_HEADER_SIZE);
// Successfully read enough bytes, so check to see if it is a GzipFile.
if (isGzipFile())
{
// It is a gzip file.
isGzip = true;
}
}
return isGzip;
}

## readHeader() [2/2]

bool GzipHeader::readHeader | ( | UncompressedFileType & | file | ) |

Definition at line 70 of file GzipHeader.cpp.

{
bool isGzip = false;
// If the file is not already open, return false.
if (!file.isOpen())
{
// File is not open, so return false - not a gzip file.
return(false);
}
// Try to read a header from the file.
// if(144 == file.read(buffer, 1, 144, filePtr))
if ((int)GZIP_HEADER_SIZE == file.read(buffer, GZIP_HEADER_SIZE))
{
memcpy(headerBuffer, buffer, GZIP_HEADER_SIZE);
// Successfully read enough bytes, so check to see if it is a GzipFile.
if (isGzipFile())
{
// It is a gzip file.
isGzip = true;
}
}
return isGzip;
}

## Member Data Documentation

## bsize

uint16_t GzipHeader::bsize

Definition at line 64 of file GzipHeader.h.

## cm

uint8_t GzipHeader::cm

Definition at line 55 of file GzipHeader.h.

## flg

uint8_t GzipHeader::flg

Definition at line 56 of file GzipHeader.h.

## headerBuffer

char GzipHeader::headerBuffer[GzipHeader::GZIP_HEADER_SIZE]

Definition at line 66 of file GzipHeader.h.

## id1

uint8_t GzipHeader::id1

Definition at line 53 of file GzipHeader.h.

## id2

uint8_t GzipHeader::id2

Definition at line 54 of file GzipHeader.h.

## mtime

uint32_t GzipHeader::mtime

Definition at line 57 of file GzipHeader.h.

## os

uint8_t GzipHeader::os

Definition at line 59 of file GzipHeader.h.

## si1

uint8_t GzipHeader::si1

Definition at line 61 of file GzipHeader.h.

## si2

uint8_t GzipHeader::si2

Definition at line 62 of file GzipHeader.h.

## slen

uint16_t GzipHeader::slen

Definition at line 63 of file GzipHeader.h.

## xfl

uint8_t GzipHeader::xfl

Definition at line 58 of file GzipHeader.h.

## xlen

uint16_t GzipHeader::xlen

Definition at line 60 of file GzipHeader.h.

The documentation for this class was generated from the following files:

- general/GzipHeader.h
- general/GzipHeader.cpp