| 60 | } |
| 61 | |
| 62 | static char *ReadFile(const char* filename, bool appendPath, size_t* outLength) { |
| 63 | FILE *fp = appendPath ? Open(filename) : fopen(filename, "rb"); |
| 64 | |
| 65 | if (!fp) { |
| 66 | *outLength = 0; |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | fseek(fp, 0, SEEK_END); |
| 71 | *outLength = static_cast<size_t>(ftell(fp)); |
| 72 | fseek(fp, 0, SEEK_SET); |
| 73 | char* buffer = static_cast<char*>(malloc(*outLength + 1)); |
| 74 | size_t readLength = fread(buffer, 1, *outLength, fp); |
| 75 | buffer[readLength] = '\0'; |
| 76 | fclose(fp); |
| 77 | return buffer; |
| 78 | } |
| 79 | |
| 80 | template <typename FileEncoding, typename MemoryEncoding> |
| 81 | void TestEncodedInputStream(const char* filename) { |