MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / createCard

Method createCard

pcsx2-qt/Settings/MemoryCardCreateDialog.cpp:99–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99void MemoryCardCreateDialog::createCard()
100{
101 const QString name = m_ui.name->text();
102 const QString type = (m_fileType == MemoryCardFileType::PS1) ? QStringLiteral("mcr") : QStringLiteral("ps2");
103 const std::string name_str = QStringLiteral("%1.%2").arg(name).arg(type).toStdString();
104 if (!Path::IsValidFileName(name_str, false))
105 {
106 QMessageBox::critical(this, tr("Create Memory Card"),
107 tr("Failed to create the Memory Card, because the name '%1' contains one or more invalid characters.").arg(name));
108 return;
109 }
110
111 if (FileMcd_GetCardInfo(name_str).has_value())
112 {
113 QMessageBox::critical(this, tr("Create Memory Card"),
114 tr("Failed to create the Memory Card, because another card with the name '%1' already exists.").arg(name));
115 return;
116 }
117
118 if (!FileMcd_CreateNewCard(name_str, m_type, m_fileType))
119 {
120 QMessageBox::critical(this, tr("Create Memory Card"),
121 tr("Failed to create the Memory Card, the log may contain more information."));
122 return;
123 }
124
125#ifdef _WIN32
126 if (m_type == MemoryCardType::File)
127 {
128 const std::string fullPath = Path::Combine(EmuFolders::MemoryCards, name_str);
129 FileSystem::SetPathCompression(fullPath.c_str(), m_ui.ntfsCompression->isChecked());
130 }
131#endif
132
133 QMessageBox::information(this, tr("Create Memory Card"), tr("Memory Card '%1' created.").arg(name));
134 accept();
135}
136
137#include "moc_MemoryCardCreateDialog.cpp"

Callers

nothing calls this directly

Calls 5

FileMcd_GetCardInfoFunction · 0.85
FileMcd_CreateNewCardFunction · 0.85
CombineFunction · 0.85
argMethod · 0.80
c_strMethod · 0.45

Tested by

no test coverage detected