| 201 | |
| 202 | |
| 203 | void QfitReader::initialize() |
| 204 | { |
| 205 | ISwitchableStream str(m_filename); |
| 206 | if (!str) |
| 207 | throwError("Unable to open file '" + m_filename + "'"); |
| 208 | str.seek(0); |
| 209 | |
| 210 | int32_t int4(0); |
| 211 | |
| 212 | str >> int4; |
| 213 | |
| 214 | // They started writting little-endian data-> |
| 215 | |
| 216 | /* For years we produced ATM data in big-endian format. With changes in |
| 217 | computer hardware, we reluctantly changed our standard output to |
| 218 | little-endian. The transition occurred between the two 2010 campaigns. The |
| 219 | format of the binary ( .qi, for example) files can be identified by |
| 220 | examining the first four bytes of the file. Read as a long integer (one |
| 221 | 4-byte word), the value will contain the record length (in bytes) of the |
| 222 | data records. For example, a .qi file containing 14 words per record will |
| 223 | have a value 56 (=4*14). If the format of the file matches the format of |
| 224 | your processor, the value will be reasonable without byte-swapping. If the |
| 225 | format of the file differs from your processor, then the value is |
| 226 | interpreted as some very large number, unless you swap the byte order. If |
| 227 | you use Intel or equivalent processors, then you had to byte-swap files |
| 228 | from spring 2010 and earlier, you do not swap the ones from fall 2010 and |
| 229 | later. */ |
| 230 | |
| 231 | // If the size comes back something other than 4*no_dimensions, we assume |
| 232 | // The data were flipped |
| 233 | if (int4 < 100) |
| 234 | { |
| 235 | m_littleEndian = true; |
| 236 | } |
| 237 | else |
| 238 | { |
| 239 | str.switchToBigEndian(); |
| 240 | } |
| 241 | |
| 242 | if (!m_littleEndian) |
| 243 | int4 = int32_t(be32toh(uint32_t(int4))); |
| 244 | |
| 245 | if (int4 % 4 != 0) |
| 246 | throwError("Base QFIT format is not a multiple of 4, " |
| 247 | "unrecognized format!"); |
| 248 | |
| 249 | m_size = int4; |
| 250 | m_format = static_cast<QFIT_Format_Type>(m_size / sizeof(m_size)); |
| 251 | |
| 252 | // The offset to start reading point data should be here. |
| 253 | str.seek(m_size + sizeof(int4)); |
| 254 | |
| 255 | str >> int4; |
| 256 | m_offset = static_cast<std::size_t>(int4); |
| 257 | |
| 258 | // Seek to the end |
| 259 | str.seek(0, std::istream::end); |
| 260 | std::ios::pos_type end = str.position(); |
nothing calls this directly
no test coverage detected