mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
GCMemcard: Implement ExportFile() to get a file on a card with a single method call.
This commit is contained in:
parent
9b14cc8ea2
commit
3e7f537a9d
@ -909,6 +909,22 @@ GCMemcardImportFileRetVal GCMemcard::ImportFile(const DEntry& direntry,
|
||||
return GCMemcardImportFileRetVal::SUCCESS;
|
||||
}
|
||||
|
||||
std::optional<Savefile> GCMemcard::ExportFile(u8 index) const
|
||||
{
|
||||
if (!m_valid || index >= DIRLEN)
|
||||
return std::nullopt;
|
||||
|
||||
Savefile savefile;
|
||||
savefile.dir_entry = GetActiveDirectory().m_dir_entries[index];
|
||||
if (savefile.dir_entry.m_gamecode == DEntry::UNINITIALIZED_GAMECODE)
|
||||
return std::nullopt;
|
||||
|
||||
if (GetSaveData(index, savefile.blocks) != GCMemcardGetSaveDataRetVal::SUCCESS)
|
||||
return std::nullopt;
|
||||
|
||||
return savefile;
|
||||
}
|
||||
|
||||
GCMemcardRemoveFileRetVal GCMemcard::RemoveFile(u8 index) // index in the directory array
|
||||
{
|
||||
if (!m_valid)
|
||||
|
@ -505,6 +505,9 @@ public:
|
||||
// adds the file to the directory and copies its contents
|
||||
GCMemcardImportFileRetVal ImportFile(const DEntry& direntry, std::vector<GCMBlock>& saveBlocks);
|
||||
|
||||
// Fetches the savefile at the given directory index, if any.
|
||||
std::optional<Savefile> ExportFile(u8 index) const;
|
||||
|
||||
// delete a file from the directory
|
||||
GCMemcardRemoveFileRetVal RemoveFile(u8 index);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user