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

Method GetFileEntryCluster

pcsx2/SIO/Memcard/MemoryCardFolder.cpp:796–836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

794}
795
796MemoryCardFileEntryCluster* FolderMemoryCard::GetFileEntryCluster(const u32 currentCluster, const u32 searchCluster, const u32 fileCount)
797{
798 // we found the correct cluster, return pointer to it
799 if (currentCluster == searchCluster)
800 {
801 return &m_fileEntryDict[currentCluster];
802 }
803
804 // check other clusters of this directory
805 const u32 nextCluster = m_fat.data[0][0][currentCluster] & NextDataClusterMask;
806 if (nextCluster != LastDataCluster)
807 {
808 MemoryCardFileEntryCluster* ptr = GetFileEntryCluster(nextCluster, searchCluster, fileCount - 2);
809 if (ptr != nullptr)
810 {
811 return ptr;
812 }
813 }
814
815 // check subdirectories
816 auto it = m_fileEntryDict.find(currentCluster);
817 if (it != m_fileEntryDict.end())
818 {
819 const u32 filesInThisCluster = std::min(fileCount, 2u);
820 for (unsigned int i = 0; i < filesInThisCluster; ++i)
821 {
822 const MemoryCardFileEntry* const entry = &it->second.entries[i];
823 if (entry->IsValid() && entry->IsUsed() && entry->IsDir() && !entry->IsDotDir())
824 {
825 const u32 newFileCount = entry->entry.data.length;
826 MemoryCardFileEntryCluster* ptr = GetFileEntryCluster(entry->entry.data.cluster, searchCluster, newFileCount);
827 if (ptr != nullptr)
828 {
829 return ptr;
830 }
831 }
832 }
833 }
834
835 return nullptr;
836}
837
838// This method is actually unused since the introduction of m_fileMetadataQuickAccess.
839// I'll leave it here anyway though to show how you traverse the file system.

Callers

nothing calls this directly

Calls 7

IsDirMethod · 0.80
IsDotDirMethod · 0.80
minFunction · 0.50
findMethod · 0.45
endMethod · 0.45
IsValidMethod · 0.45
IsUsedMethod · 0.45

Tested by

no test coverage detected