| 113 | |
| 114 | |
| 115 | void BedFile::Open(void) { |
| 116 | |
| 117 | _bedFields.reserve(12); |
| 118 | |
| 119 | if (bedFile == "stdin" || bedFile == "-") { |
| 120 | _bedStream = &cin; |
| 121 | } |
| 122 | else { |
| 123 | _bedStream = new ifstream(bedFile.c_str(), ios::in); |
| 124 | |
| 125 | if( isGzipFile(_bedStream) ) { |
| 126 | delete _bedStream; |
| 127 | _bedStream = new igzstream(bedFile.c_str(), ios::in); |
| 128 | } |
| 129 | if ( _bedStream->fail() ) { |
| 130 | cerr << "Error: The requested file (" |
| 131 | << bedFile |
| 132 | << ") " |
| 133 | << "could not be opened. " |
| 134 | << "Error message: (" |
| 135 | << strerror(errno) |
| 136 | << "). Exiting!" << endl; |
| 137 | exit (1); |
| 138 | } |
| 139 | } |
| 140 | // save the file's header (if there is one) |
| 141 | GetHeader(); |
| 142 | } |
| 143 | |
| 144 | // Rewind the pointer back to the beginning of the file |
| 145 | void BedFile::Rewind(void) { |
nothing calls this directly
no test coverage detected