| 136 | } |
| 137 | |
| 138 | int |
| 139 | BinaryFileStream::open(void) |
| 140 | { |
| 141 | // check setFile has been called |
| 142 | if (fileName == 0) { |
| 143 | std::cerr << "BinaryFileStream::open(void) - no file name has been set\n"; |
| 144 | return -1; |
| 145 | } |
| 146 | |
| 147 | // if file already open, return |
| 148 | if (fileOpen == 1) { |
| 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | if (theOpenMode == OVERWRITE) |
| 153 | theFile.open(fileName, ios::out | ios::binary); |
| 154 | else |
| 155 | theFile.open(fileName, ios::out | ios::app | ios::binary); |
| 156 | |
| 157 | theOpenMode = APPEND; |
| 158 | |
| 159 | if (theFile.bad()) { |
| 160 | std::cerr << "WARNING - BinaryFileStream::setFile()"; |
| 161 | std::cerr << " - could not open file " << fileName << std::endl; |
| 162 | fileOpen = 0; |
| 163 | return -1; |
| 164 | } else |
| 165 | fileOpen = 1; |
| 166 | |
| 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | int |
| 171 | BinaryFileStream::close(void) |
no outgoing calls
no test coverage detected