| 53 | } |
| 54 | |
| 55 | int vtkMultiBlockPLOT3DReaderInternals::CheckByteOrder(FILE* fp) |
| 56 | { |
| 57 | clearerr(fp); // clear error and EOF flags |
| 58 | fseek(fp, 0, SEEK_SET); // move to beginning |
| 59 | int i; |
| 60 | if (fread(&i, sizeof(int), 1, fp) < 1) |
| 61 | { |
| 62 | return 0; |
| 63 | } |
| 64 | char* cpy = (char*)&i; |
| 65 | |
| 66 | // If binary, we can assume that the first value is going to be either a |
| 67 | // count (Fortran) or a number of block or a dimension. We assume that |
| 68 | // this number will be smaller than 2^24. Then we check the first byte. |
| 69 | // If it is 0 and the last byte is not 0, it is likely that this is big |
| 70 | // endian. |
| 71 | if (cpy[0] == 0 && cpy[3] != 0) |
| 72 | { |
| 73 | this->Settings.ByteOrder = vtkMultiBlockPLOT3DReader::FILE_BIG_ENDIAN; |
| 74 | } |
| 75 | else |
| 76 | { |
| 77 | this->Settings.ByteOrder = vtkMultiBlockPLOT3DReader::FILE_LITTLE_ENDIAN; |
| 78 | } |
| 79 | return 1; |
| 80 | } |
| 81 | |
| 82 | int vtkMultiBlockPLOT3DReaderInternals::CheckByteCount(FILE* fp) |
| 83 | { |