| 114 | } |
| 115 | |
| 116 | SMCError TextParsers::ParseSMCFile(const char *file, |
| 117 | ITextListener_SMC *smc_listener, |
| 118 | SMCStates *states, |
| 119 | char *buffer, |
| 120 | size_t maxsize) |
| 121 | { |
| 122 | const char *errstr; |
| 123 | FILE *fp = fopen(file, "rt"); |
| 124 | |
| 125 | if (fp == NULL) |
| 126 | { |
| 127 | char error[256] = "unknown"; |
| 128 | if (states != NULL) |
| 129 | { |
| 130 | states->line = 0; |
| 131 | states->col = 0; |
| 132 | } |
| 133 | //g_LibSys.GetPlatformError(error, sizeof(error)); |
| 134 | UTIL_Format(buffer, maxsize, "File could not be opened: %s", error); |
| 135 | return SMCError_StreamOpen; |
| 136 | } |
| 137 | |
| 138 | SMCError result = ParseStream_SMC(fp, FileStreamReader, smc_listener, states); |
| 139 | |
| 140 | fclose(fp); |
| 141 | |
| 142 | errstr = GetSMCErrorString(result); |
| 143 | UTIL_Format(buffer, maxsize, "%s", errstr != NULL ? errstr : "Unknown error"); |
| 144 | |
| 145 | return result; |
| 146 | } |
| 147 | |
| 148 | struct RawStream |
| 149 | { |
no test coverage detected