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

Method Open

pcsx2/SIO/Memcard/MemoryCardFile.cpp:262–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260FileMemoryCard::~FileMemoryCard() = default;
261
262void FileMemoryCard::Open()
263{
264 for (int slot = 0; slot < 8; ++slot)
265 {
266 m_filenames[slot] = {};
267
268 if (EmuConfig.Mcd[slot].Type != MemoryCardType::File)
269 continue;
270
271 if (FileMcd_IsMultitapSlot(slot))
272 {
273 if (!EmuConfig.Pad.MultitapPort0_Enabled && (FileMcd_GetMtapPort(slot) == 0))
274 continue;
275 if (!EmuConfig.Pad.MultitapPort1_Enabled && (FileMcd_GetMtapPort(slot) == 1))
276 continue;
277 }
278
279 const std::string fname = EmuConfig.FullpathToMcd(slot);
280
281 if (!EmuConfig.Mcd[slot].Enabled || fname.empty())
282 {
283 Console.WriteLnFmt("McdSlot {} [File]: [disabled/empty filename]", slot);
284 continue;
285 }
286
287 if (FileSystem::GetPathFileSize(fname.c_str()) <= 0)
288 {
289 if (!Create(fname.c_str(), 8))
290 {
291 Host::ReportErrorAsync(TRANSLATE_SV("MemoryCard", "Memory Card Creation Failed"),
292 fmt::format(TRANSLATE_FS("MemoryCard", "Could not create the memory card:\n{}"),
293 fname));
294 }
295 }
296
297 if (fname.ends_with(".bin") || fname.ends_with(".mc2"))
298 {
299 std::string newname(fname + "x");
300 if (!ConvertNoECCtoRAW(fname.c_str(), newname.c_str()))
301 {
302 Console.Error("Could convert memory card: %s", fname.c_str());
303 FileSystem::DeleteFilePath(newname.c_str());
304 continue;
305 }
306
307 // store the original filename
308 m_file[slot] = FileSystem::OpenSharedCFile(newname.c_str(), "r+b", FileSystem::FileShareMode::DenyWrite);
309 }
310 else
311 {
312 m_file[slot] = FileSystem::OpenSharedCFile(fname.c_str(), "r+b", FileSystem::FileShareMode::DenyWrite);
313 }
314
315 if (!m_file[slot])
316 {
317 Host::ReportErrorAsync(TRANSLATE_SV("MemoryCard", "Memory Card Read Failed"),
318 fmt::format(TRANSLATE_FS("MemoryCard", "Unable to access memory card:\n\n{}\n\n"
319 "Another instance of PCSX2 may be using this memory card "

Callers 2

FileMcd_EmuOpenFunction · 0.45

Calls 12

FileMcd_IsMultitapSlotFunction · 0.85
FileMcd_GetMtapPortFunction · 0.85
ConvertNoECCtoRAWFunction · 0.85
FullpathToMcdMethod · 0.80
ends_withMethod · 0.80
CreateFunction · 0.50
formatFunction · 0.50
emptyMethod · 0.45
WriteLnFmtMethod · 0.45
c_strMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected