mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-24 12:44:10 +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:
@@ -194,13 +194,13 @@ void IniLoadFile::LoadFromDisk(const std::string &filename, Subdirectory subdir)
|
||||
std::string comment;
|
||||
|
||||
size_t end;
|
||||
FILE *in = this->OpenFile(filename, subdir, &end);
|
||||
if (in == nullptr) return;
|
||||
auto in = this->OpenFile(filename, subdir, &end);
|
||||
if (!in.has_value()) return;
|
||||
|
||||
end += ftell(in);
|
||||
end += ftell(*in);
|
||||
|
||||
/* for each line in the file */
|
||||
while (static_cast<size_t>(ftell(in)) < end && fgets(buffer, sizeof(buffer), in)) {
|
||||
while (static_cast<size_t>(ftell(*in)) < end && fgets(buffer, sizeof(buffer), *in)) {
|
||||
char c, *s;
|
||||
/* trim whitespace from the left side */
|
||||
for (s = buffer; *s == ' ' || *s == '\t'; s++) {}
|
||||
@@ -272,7 +272,5 @@ void IniLoadFile::LoadFromDisk(const std::string &filename, Subdirectory subdir)
|
||||
}
|
||||
|
||||
this->comment = std::move(comment);
|
||||
|
||||
fclose(in);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user