Skip to content

Commit

Permalink
pcsx2/SIO: correctly detect whether format status of folder mcd
Browse files Browse the repository at this point in the history
  • Loading branch information
GovanifY committed Feb 20, 2025
1 parent 009b4ff commit 1dc009f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 0 additions & 3 deletions pcsx2-qt/Settings/MemoryCardSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ QString MemoryCardSettingsWidget::getSelectedCard() const

bool MemoryCardSettingsWidget::isSelectedCardFormatted() const
{
QString ret;

const QList<QTreeWidgetItem*> selection(m_ui.cardList->selectedItems());
if (!selection.empty())
return selection[0]->data(0, Qt::UserRole).toBool();
Expand Down Expand Up @@ -279,7 +277,6 @@ void MemoryCardSettingsWidget::convertCard()
return;
}


MemoryCardConvertDialog dialog(QtUtils::GetRootWidget(this), selectedCard);

if (dialog.IsSetup() && dialog.exec() == QDialog::Accepted)
Expand Down
9 changes: 8 additions & 1 deletion pcsx2/SIO/Memcard/MemoryCardFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,15 @@ std::vector<AvailableMcdInfo> FileMcd_GetAvailableCards(bool include_in_use_card
if (!IsMemoryCardFolder(fd.FileName))
continue;

FolderMemoryCard sourceFolderMemoryCard;
Pcsx2Config::McdOptions config;
config.Enabled = true;
config.Type = MemoryCardType::Folder;
sourceFolderMemoryCard.Open(fd.FileName, config, (8 * 1024 * 1024) / FolderMemoryCard::ClusterSize, false, "");

mcds.push_back({std::move(basename), std::move(fd.FileName), fd.ModificationTime,
MemoryCardType::Folder, MemoryCardFileType::Unknown, 0u, true});
MemoryCardType::Folder, MemoryCardFileType::Unknown, 0u, sourceFolderMemoryCard.IsFormatted()});
sourceFolderMemoryCard.Close(false);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions pcsx2/SIO/Memcard/MemoryCardFolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ class FolderMemoryCard
void Open(std::string fullPath, const Pcsx2Config::McdOptions& mcdOptions, const u32 sizeInClusters, const bool enableFiltering, std::string filter, bool simulateFileWrites = false);
// Close the memory card and flush changes to the file system. Set flush to false to not store changes.
void Close(bool flush = true);
// Checks whether the Memory Card is formatted.
bool IsFormatted() const;

// Closes and reopens card with given filter options if they differ from the current ones (returns true),
// or does nothing if they match already (returns false).
Expand Down Expand Up @@ -363,8 +365,6 @@ class FolderMemoryCard
// initializes memory card data, as if it was fresh from the factory
void InitializeInternalData();

bool IsFormatted() const;

// returns the in-memory address of data the given memory card adr corresponds to
// returns nullptr if adr corresponds to a folder or file entry
u8* GetSystemBlockPointer(const u32 adr);
Expand Down Expand Up @@ -558,4 +558,4 @@ class FolderMemoryCardAggregator
u64 GetCRC(uint slot);
void NextFrame(uint slot);
bool ReIndex(uint slot, const bool enableFiltering, const std::string& filter);
};
};

0 comments on commit 1dc009f

Please sign in to comment.