2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 21:07:42 +00:00

General: Make use of FopenUnique where applicable

Migrates to the hecl Fopen variant that automatically closes its
contained file handle if it goes out of scope.
This commit is contained in:
Lioncash
2019-08-26 14:37:19 -04:00
parent f48ebefa84
commit 1d3062b33f
9 changed files with 60 additions and 73 deletions

View File

@@ -466,9 +466,8 @@ bool PAKRouter<BRIDGETYPE>::extractResources(const BRIDGETYPE& pakBridge, bool f
if (force || cooked.isNone()) {
cooked.makeDirChain(false);
PAKEntryReadStream s = entryPtr->beginReadStream(*node);
FILE* fout = hecl::Fopen(cooked.getAbsolutePath().data(), _SYS_STR("wb"));
fwrite(s.data(), 1, s.length(), fout);
fclose(fout);
const auto fout = hecl::FopenUnique(cooked.getAbsolutePath().data(), _SYS_STR("wb"));
std::fwrite(s.data(), 1, s.length(), fout.get());
}
if (extractor.func_a) /* Doesn't need PAKRouter access */