mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-16 17:02:37 +01:00
Codechange: Replace all FILE * with FileHandle RAII class. (#12718)
This removes the need to manually ensure all files are closed.
This commit is contained in:
@@ -2043,11 +2043,10 @@ const LanguageMetadata *GetLanguage(uint8_t newgrflangid)
|
||||
*/
|
||||
static bool GetLanguageFileHeader(const std::string &file, LanguagePackHeader *hdr)
|
||||
{
|
||||
FILE *f = fopen(file.c_str(), "rb");
|
||||
if (f == nullptr) return false;
|
||||
auto f = FileHandle::Open(file, "rb");
|
||||
if (!f.has_value()) return false;
|
||||
|
||||
size_t read = fread(hdr, sizeof(*hdr), 1, f);
|
||||
fclose(f);
|
||||
size_t read = fread(hdr, sizeof(*hdr), 1, *f);
|
||||
|
||||
bool ret = read == 1 && hdr->IsValid();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user