| 150 | } |
| 151 | |
| 152 | int |
| 153 | BinaryFileStream::open(void) |
| 154 | { |
| 155 | // check setFile has been called |
| 156 | if (fileName == 0) { |
| 157 | std::cerr << "BinaryFileStream::open(void) - no file name has been set\n"; |
| 158 | return -1; |
| 159 | } |
| 160 | |
| 161 | // if file already open, return |
| 162 | if (fileOpen == 1) { |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | if (theOpenMode == openMode::OVERWRITE) |
| 167 | theFile.open(fileName, ios::out | ios::binary); |
| 168 | else |
| 169 | theFile.open(fileName, ios::out | ios::app | ios::binary); |
| 170 | |
| 171 | theOpenMode = openMode::APPEND; |
| 172 | |
| 173 | if (theFile.bad()) { |
| 174 | std::cerr << "WARNING - BinaryFileStream::setFile()"; |
| 175 | std::cerr << " - could not open file " << fileName << std::endl; |
| 176 | fileOpen = 0; |
| 177 | return -1; |
| 178 | } else |
| 179 | fileOpen = 1; |
| 180 | |
| 181 | return 0; |
| 182 | } |
| 183 | |
| 184 | int |
| 185 | BinaryFileStream::close(void) |
no outgoing calls
no test coverage detected