mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-26 15:50:00 -06:00
Slight fixups with FATStorage
(#1934)
* Reload the SD card for `CartSD` and all subclasses * Make `ROMManager::LoadDLDISDCard` delegate to `GetDLDISDCardArgs` * Add a method overload for `CartSD::SetSDCard` * Initialize new SD card images with the correct size * Sync the old card to the host (if applicable) when move-assigning a new one * Only sync the old card to the host if it's not read-only * Remove static state in `FATStorage` - Replace `FF_ReadStorage` and `FF_WriteStorage` with lambda functions - Keep open and use the single `File` handle throughout the `FATStorage`'s life
This commit is contained in:
@ -260,6 +260,22 @@ public:
|
||||
// it just leaves behind an optional with a moved-from value
|
||||
}
|
||||
|
||||
void SetSDCard(std::optional<FATStorageArgs>&& args) noexcept
|
||||
{
|
||||
// Close the open SD card (if any) so that its contents are flushed to disk.
|
||||
// Also, if args refers to the same image file that SD is currently using,
|
||||
// this will ensure that we don't have two open read-write handles
|
||||
// to the same file.
|
||||
SD = std::nullopt;
|
||||
|
||||
if (args)
|
||||
SD = FATStorage(std::move(*args));
|
||||
|
||||
args = std::nullopt;
|
||||
// moving from an optional doesn't set it to nullopt,
|
||||
// it just leaves behind an optional with a moved-from value
|
||||
}
|
||||
|
||||
protected:
|
||||
void ApplyDLDIPatchAt(u8* binary, u32 dldioffset, const u8* patch, u32 patchlen, bool readonly) const;
|
||||
void ApplyDLDIPatch(const u8* patch, u32 patchlen, bool readonly);
|
||||
|
Reference in New Issue
Block a user