* Reads the language file header and checks compatibility. * @param file the file to read * @param hdr the place to write the header information to * @return true if and only if the language file is of a compatible version */
| 2197 | * @return true if and only if the language file is of a compatible version |
| 2198 | */ |
| 2199 | static bool GetLanguageFileHeader(const std::string &file, LanguagePackHeader *hdr) |
| 2200 | { |
| 2201 | auto f = FileHandle::Open(file, "rb"); |
| 2202 | if (!f.has_value()) return false; |
| 2203 | |
| 2204 | size_t read = fread(hdr, sizeof(*hdr), 1, *f); |
| 2205 | |
| 2206 | bool ret = read == 1 && hdr->IsValid(); |
| 2207 | |
| 2208 | /* Convert endianness for the windows language ID */ |
| 2209 | if (ret) { |
| 2210 | hdr->missing = FROM_LE16(hdr->missing); |
| 2211 | hdr->winlangid = FROM_LE16(hdr->winlangid); |
| 2212 | } |
| 2213 | return ret; |
| 2214 | } |
| 2215 | |
| 2216 | /** |
| 2217 | * Search for the languages in the given directory and add them to the #_languages list. |
no test coverage detected