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

Method Close

pcsx2/SIO/Memcard/MemoryCardFile.cpp:346–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344}
345
346void FileMemoryCard::Close()
347{
348 for (int slot = 0; slot < 8; ++slot)
349 {
350 if (!m_file[slot])
351 continue;
352
353 // Store checksum
354 if (!m_ispsx[slot] && FileSystem::FSeek64(m_file[slot], m_chkaddr, SEEK_SET) == 0)
355 std::fwrite(&m_chksum[slot], sizeof(m_chksum[slot]), 1, m_file[slot]);
356
357 std::fclose(m_file[slot]);
358 m_file[slot] = nullptr;
359
360 if (m_filenames[slot].ends_with(".bin") || m_filenames[slot].ends_with(".mc2"))
361 {
362 const std::string name_in(m_filenames[slot] + 'x');
363 if (ConvertRAWtoNoECC(name_in.c_str(), m_filenames[slot].c_str()))
364 FileSystem::DeleteFilePath(name_in.c_str());
365 }
366
367 m_filenames[slot] = {};
368 m_fileSize[slot] = -1;
369 }
370}
371
372// Returns FALSE if the seek failed (is outside the bounds of the file).
373bool FileMemoryCard::Seek(std::FILE* f, u32 adr)

Callers 2

FileMcd_EmuCloseFunction · 0.45

Calls 3

ConvertRAWtoNoECCFunction · 0.85
ends_withMethod · 0.80
c_strMethod · 0.45

Tested by

no test coverage detected