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

Method GetFileEntryFromFileDataCluster

pcsx2/SIO/Memcard/MemoryCardFolder.cpp:840–893  ·  view source on GitHub ↗

This method is actually unused since the introduction of m_fileMetadataQuickAccess. I'll leave it here anyway though to show how you traverse the file system.

Source from the content-addressed store, hash-verified

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.
840MemoryCardFileEntry* FolderMemoryCard::GetFileEntryFromFileDataCluster(const u32 currentCluster, const u32 searchCluster, std::string* fileName, const size_t originalDirCount, u32* outClusterNumber)
841{
842 // check both entries of the current cluster if they're the file we're searching for, and if yes return it
843 for (int i = 0; i < 2; ++i)
844 {
845 MemoryCardFileEntry* const entry = &m_fileEntryDict[currentCluster].entries[i];
846 if (entry->IsValid() && entry->IsUsed() && entry->IsFile())
847 {
848 u32 fileCluster = entry->entry.data.cluster;
849 u32 clusterNumber = 0;
850 do
851 {
852 if (fileCluster == searchCluster)
853 {
854 Path::ChangeFileName(fileName, (const char*)entry->entry.data.name);
855 *outClusterNumber = clusterNumber;
856 return entry;
857 }
858 ++clusterNumber;
859 } while ((fileCluster = m_fat.data[0][0][fileCluster] & NextDataClusterMask) != LastDataCluster);
860 }
861 }
862
863 // check other clusters of this directory
864 // this can probably be solved more efficiently by looping through nextClusters instead of recursively calling
865 const u32 nextCluster = m_fat.data[0][0][currentCluster] & NextDataClusterMask;
866 if (nextCluster != LastDataCluster)
867 {
868 MemoryCardFileEntry* ptr = GetFileEntryFromFileDataCluster(nextCluster, searchCluster, fileName, originalDirCount, outClusterNumber);
869 if (ptr != nullptr)
870 {
871 return ptr;
872 }
873 }
874
875 // check subdirectories
876 for (int i = 0; i < 2; ++i)
877 {
878 MemoryCardFileEntry* const entry = &m_fileEntryDict[currentCluster].entries[i];
879 if (entry->IsValid() && entry->IsUsed() && entry->IsDir() && !entry->IsDotDir())
880 {
881 MemoryCardFileEntry* ptr = GetFileEntryFromFileDataCluster(entry->entry.data.cluster, searchCluster, fileName, originalDirCount, outClusterNumber);
882 if (ptr != nullptr)
883 {
884 std::vector<std::string_view> components(Path::SplitNativePath(*fileName));
885 components.insert(components.begin() + originalDirCount, (const char*)entry->entry.data.name);
886 *fileName = Path::JoinNativePath(components);
887 return ptr;
888 }
889 }
890 }
891
892 return nullptr;
893}
894
895bool FolderMemoryCard::ReadFromFile(u8* dest, u32 adr, u32 dataLength)
896{

Callers

nothing calls this directly

Calls 7

IsFileMethod · 0.80
IsDirMethod · 0.80
IsDotDirMethod · 0.80
IsValidMethod · 0.45
IsUsedMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected