MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / WasFileCorrectlyRead

Function WasFileCorrectlyRead

tools/io.cpp:54–67  ·  view source on GitHub ↗

Returns true if |file| has encountered an error opening the file or reading from it. If there was an error, writes an error message to standard error.

Source from the content-addressed store, hash-verified

52// Returns true if |file| has encountered an error opening the file or reading
53// from it. If there was an error, writes an error message to standard error.
54bool WasFileCorrectlyRead(FILE* file, const char* filename) {
55 if (file == nullptr) {
56 fprintf(stderr, "error: file does not exist '%s'\n", filename);
57 return false;
58 }
59
60 if (ftell(file) == -1L) {
61 if (ferror(file)) {
62 fprintf(stderr, "error: error reading file '%s'\n", filename);
63 return false;
64 }
65 }
66 return true;
67}
68
69// Ensure the file contained an exact number of elements, whose size is given in
70// |alignment|.

Callers 2

ReadBinaryFileFunction · 0.85
ReadTextFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected