BgzfFileType.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifdef __ZLIB_AVAILABLE__
00019
00020 #include <iostream>
00021 #include <string.h>
00022
00023 #include "BgzfFileType.h"
00024
00025
00026 bool BgzfFileType::ourRequireEofBlock = true;
00027
00028 BgzfFileType::BgzfFileType(const char * filename, const char * mode)
00029 {
00030
00031 if(((mode[0] == 'w') || (mode[0] == 'W')) &&
00032 (strcmp(filename, "-") == 0))
00033 {
00034
00035 bgzfHandle = bgzf_fdopen(fileno(stdout), mode);
00036 }
00037 else if(((mode[0] == 'r') || (mode[0] == 'R')) &&
00038 (strcmp(filename, "-") == 0))
00039 {
00040
00041 bgzfHandle = bgzf_fdopen(fileno(stdin), mode);
00042 }
00043 else
00044 {
00045 bgzfHandle = bgzf_open(filename, mode);
00046 }
00047
00048 myStartPos = 0;
00049 if (bgzfHandle != NULL)
00050 {
00051
00052
00053 if ((mode[0] == 'r' || mode[0] == 'R') && ourRequireEofBlock &&
00054 (bgzf_check_EOF(bgzfHandle) == 0))
00055 {
00056 std::cerr << "BGZF EOF marker is missing in " << filename << std::endl;
00057
00058 close();
00059 }
00060 else
00061 {
00062
00063
00064 myStartPos = bgzf_tell(bgzfHandle);
00065 }
00066 }
00067
00068 myEOF = false;
00069 }
00070
00071
00072
00073
00074 void BgzfFileType::setRequireEofBlock(bool requireEofBlock)
00075 {
00076 ourRequireEofBlock = requireEofBlock;
00077 }
00078
00079 #endif