mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-22 03:42:41 +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:
@@ -742,15 +742,14 @@ static std::vector<char> Xunzip(std::span<char> input)
|
||||
|
||||
/* Get text from file */
|
||||
size_t filesize;
|
||||
FILE *handle = FioFOpenFile(textfile, "rb", dir, &filesize);
|
||||
if (handle == nullptr) return;
|
||||
auto handle = FioFOpenFile(textfile, "rb", dir, &filesize);
|
||||
if (!handle.has_value()) return;
|
||||
/* Early return on empty files. */
|
||||
if (filesize == 0) return;
|
||||
|
||||
std::vector<char> buf;
|
||||
buf.resize(filesize);
|
||||
size_t read = fread(buf.data(), 1, buf.size(), handle);
|
||||
fclose(handle);
|
||||
size_t read = fread(buf.data(), 1, buf.size(), *handle);
|
||||
|
||||
if (read != buf.size()) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user