mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 15:44:56 +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:
@@ -39,10 +39,10 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl
|
||||
return {};
|
||||
|
||||
path += fmt::format(fmt("/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
||||
FILE* fp = hecl::Fopen(path.c_str(), "wb");
|
||||
if (!fp)
|
||||
const auto fp = hecl::FopenUnique(path.c_str(), "wb");
|
||||
if (fp == nullptr) {
|
||||
return {};
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl
|
||||
return {};
|
||||
|
||||
path += fmt::format(fmt("/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
||||
FILE* fp = hecl::Fopen(path.c_str(), "wb");
|
||||
if (!fp)
|
||||
const auto fp = hecl::FopenUnique(path.c_str(), "wb");
|
||||
if (fp == nullptr) {
|
||||
return {};
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -100,10 +100,10 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl
|
||||
|
||||
path += fmt::format(fmt(_SYS_STR("/MemoryCard{}.USA.raw")),
|
||||
slot == kabufuda::ECardSlot::SlotA ? _SYS_STR('A') : _SYS_STR('B'));
|
||||
FILE* fp = hecl::Fopen(path.c_str(), _SYS_STR("wb"));
|
||||
if (!fp)
|
||||
const auto fp = hecl::FopenUnique(path.c_str(), _SYS_STR("wb"));
|
||||
if (fp == nullptr) {
|
||||
return {};
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user