MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetLanguageFileHeader

Function GetLanguageFileHeader

src/strings.cpp:2199–2214  ·  view source on GitHub ↗

* 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 */

Source from the content-addressed store, hash-verified

2197 * @return true if and only if the language file is of a compatible version
2198 */
2199static 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.

Callers 1

FillLanguageListFunction · 0.85

Calls 2

FROM_LE16Function · 0.85
IsValidMethod · 0.45

Tested by

no test coverage detected