GCMemcardManager: Detect attempt to import multiple save files with the same internal name.
This commit is contained in:
parent
74b56a8c7f
commit
e47eb16641
|
@ -72,6 +72,19 @@ bool HasSameIdentity(const DEntry& lhs, const DEntry& rhs)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool HasDuplicateIdentity(const std::vector<Savefile>& savefiles)
|
||||
{
|
||||
for (size_t i = 0; i < savefiles.size(); ++i)
|
||||
{
|
||||
for (size_t j = i + 1; j < savefiles.size(); ++j)
|
||||
{
|
||||
if (HasSameIdentity(savefiles[i].dir_entry, savefiles[j].dir_entry))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void ByteswapDEntrySavHeader(std::array<u8, DENTRY_SIZE>& entry)
|
||||
{
|
||||
// several bytes in SAV are swapped compared to the internal memory card format
|
||||
|
|
|
@ -13,6 +13,9 @@ namespace Memcard
|
|||
{
|
||||
bool HasSameIdentity(const DEntry& lhs, const DEntry& rhs);
|
||||
|
||||
// Check if any two given savefiles have the same identity.
|
||||
bool HasDuplicateIdentity(const std::vector<Savefile>& savefiles);
|
||||
|
||||
enum class ReadSavefileErrorCode
|
||||
{
|
||||
OpenFileFail,
|
||||
|
|
|
@ -515,6 +515,12 @@ void GCMemcardManager::ImportFiles(int slot, const std::vector<Memcard::Savefile
|
|||
"", static_cast<int>(number_of_blocks)));
|
||||
}
|
||||
|
||||
if (Memcard::HasDuplicateIdentity(savefiles))
|
||||
{
|
||||
error_messages.push_back(
|
||||
tr("At least two of the selected save files have the same internal filename."));
|
||||
}
|
||||
|
||||
for (const Memcard::Savefile& savefile : savefiles)
|
||||
{
|
||||
if (card->TitlePresent(savefile.dir_entry))
|
||||
|
|
Loading…
Reference in New Issue