MCPcopy Create free account
hub / github.com/Kitware/VTK / CheckBinaryFile

Method CheckBinaryFile

IO/Parallel/vtkMultiBlockPLOT3DReaderInternals.cxx:23–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23int vtkMultiBlockPLOT3DReaderInternals::CheckBinaryFile(FILE* fp, size_t fileSize)
24{
25 clearerr(fp); // clear error and EOF flags
26 fseek(fp, 0, SEEK_SET); // move to beginning
27 this->Settings.BinaryFile = 0;
28
29 // The shortest binary file is 12 files: 2 ints for block dims + 1 float for
30 // a coordinate.
31 if (fileSize < 12)
32 {
33 return 0;
34 }
35
36 char bytes[12];
37 if (fread(bytes, 1, 12, fp) != 12)
38 {
39 return 0;
40 }
41 // Check the first 12 bytes. If we find non-ascii characters, then we
42 // assume that it is binary.
43 for (int i = 0; i < 12; i++)
44 {
45 if (!(isdigit(bytes[i]) || bytes[i] == '.' || bytes[i] == ' ' || bytes[i] == '\r' ||
46 bytes[i] == '\n' || bytes[i] == '\t'))
47 {
48 this->Settings.BinaryFile = 1;
49 return 1;
50 }
51 }
52 return 1;
53}
54
55int vtkMultiBlockPLOT3DReaderInternals::CheckByteOrder(FILE* fp)
56{

Callers 1

AutoDetectionCheckMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected