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

Method ReOpen

pcsx2/SIO/Memcard/MemoryCardFolder.cpp:2111–2146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2109}
2110
2111std::FILE* FileAccessHelper::ReOpen(const std::string_view folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata /* = false */)
2112{
2113 std::string internalPath;
2114 fileRef->GetInternalPath(&internalPath);
2115 auto it = m_files.find(internalPath);
2116 if (it != m_files.end())
2117 {
2118 // we already have a handle to this file
2119
2120 // if the caller wants to write metadata and we haven't done this recently, do so and remember that we did
2121 if (writeMetadata)
2122 {
2123 if (m_lastWrittenFileRef != fileRef)
2124 {
2125 WriteMetadata(folderName, fileRef);
2126 m_lastWrittenFileRef = fileRef;
2127 }
2128 }
2129 else
2130 {
2131 if (m_lastWrittenFileRef != nullptr)
2132 {
2133 m_lastWrittenFileRef = nullptr;
2134 }
2135 }
2136
2137 // update the fileRef in the map since it might have been modified or deleted
2138 it->second.fileRef = fileRef;
2139
2140 return it->second.fileHandle;
2141 }
2142 else
2143 {
2144 return this->Open(folderName, fileRef, writeMetadata);
2145 }
2146}
2147
2148void FileAccessHelper::CloseFileHandle(std::FILE*& file, const MemoryCardFileEntry* entry /* = nullptr */)
2149{

Callers 3

AddFileMethod · 0.80
ReadFromFileMethod · 0.80
WriteToFileMethod · 0.80

Calls 4

GetInternalPathMethod · 0.80
findMethod · 0.45
endMethod · 0.45
OpenMethod · 0.45

Tested by

no test coverage detected