Fixed issue with the fs/save example where the FsSaveDataInfoReader was not closed when a save was found successfully.

This commit is contained in:
yellows8 2020-04-03 00:23:04 -04:00
parent 948ce48e58
commit a34aba3b72
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43

View File

@ -11,6 +11,7 @@ Result get_save(u64 *application_id, AccountUid *uid) {
FsSaveDataInfoReader reader;
s64 total_entries=0;
FsSaveDataInfo info;
bool found=0;
rc = fsOpenSaveDataInfoReader(&reader, FsSaveDataSpaceId_User);//See libnx fs.h.
if (R_FAILED(rc)) {
@ -26,13 +27,14 @@ Result get_save(u64 *application_id, AccountUid *uid) {
if (info.save_data_type == FsSaveDataType_Account) {//Filter by FsSaveDataType_Account, however note that FsSaveDataSpaceId_User can have non-FsSaveDataType_Account.
*application_id = info.application_id;
*uid = info.uid;
return 0;
found = 1;
break;
}
}
fsSaveDataInfoReaderClose(&reader);
if (R_SUCCEEDED(rc)) return MAKERESULT(Module_Libnx, LibnxError_NotFound);
if (R_SUCCEEDED(rc) && !found) return MAKERESULT(Module_Libnx, LibnxError_NotFound);
return rc;
}