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:
@@ -168,11 +168,11 @@ struct ScriptFileChecksumCreator : FileScanner {
|
||||
size_t len, size;
|
||||
|
||||
/* Open the file ... */
|
||||
FILE *f = FioFOpenFile(filename, "rb", this->dir, &size);
|
||||
if (f == nullptr) return false;
|
||||
auto f = FioFOpenFile(filename, "rb", this->dir, &size);
|
||||
if (!f.has_value()) return false;
|
||||
|
||||
/* ... calculate md5sum... */
|
||||
while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, f)) != 0 && size != 0) {
|
||||
while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, *f)) != 0 && size != 0) {
|
||||
size -= len;
|
||||
checksum.Append(buffer, len);
|
||||
}
|
||||
@@ -180,8 +180,6 @@ struct ScriptFileChecksumCreator : FileScanner {
|
||||
MD5Hash tmp_md5sum;
|
||||
checksum.Finish(tmp_md5sum);
|
||||
|
||||
FioFCloseFile(f);
|
||||
|
||||
/* ... and xor it to the overall md5sum. */
|
||||
this->md5sum ^= tmp_md5sum;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user