diff --git a/pcsx2/gui/MemoryCardFolder.cpp b/pcsx2/gui/MemoryCardFolder.cpp index 1b90d8f13a..6a7bb84f7e 100644 --- a/pcsx2/gui/MemoryCardFolder.cpp +++ b/pcsx2/gui/MemoryCardFolder.cpp @@ -576,7 +576,7 @@ MemoryCardFileEntryCluster* FolderMemoryCard::GetFileEntryCluster( const u32 cur const u32 filesInThisCluster = std::min( fileCount, 2u ); for ( unsigned int i = 0; i < filesInThisCluster; ++i ) { MemoryCardFileEntry* const entry = &it->second.entries[i]; - if ( entry->IsValid() && entry->IsUsed() && entry->IsDir() && entry->entry.data.cluster != 0 ) { + if ( entry->IsValid() && entry->IsUsed() && entry->IsDir() && !entry->IsDotDir() ) { const u32 newFileCount = entry->entry.data.length; MemoryCardFileEntryCluster* ptr = GetFileEntryCluster( entry->entry.data.cluster, searchCluster, newFileCount ); if ( ptr != nullptr ) { return ptr; } @@ -618,7 +618,7 @@ MemoryCardFileEntry* FolderMemoryCard::GetFileEntryFromFileDataCluster( const u3 // check subdirectories for ( int i = 0; i < 2; ++i ) { MemoryCardFileEntry* const entry = &m_fileEntryDict[currentCluster].entries[i]; - if ( entry->IsValid() && entry->IsUsed() && entry->IsDir() && entry->entry.data.cluster != 0 ) { + if ( entry->IsValid() && entry->IsUsed() && entry->IsDir() && !entry->IsDotDir() ) { MemoryCardFileEntry* ptr = GetFileEntryFromFileDataCluster( entry->entry.data.cluster, searchCluster, fileName, originalDirCount, outClusterNumber ); if ( ptr != nullptr ) { fileName->InsertDir( originalDirCount, wxString::FromAscii( (const char*)entry->entry.data.name ) ); @@ -863,8 +863,7 @@ void FolderMemoryCard::FlushFileEntries( const u32 dirCluster, const u32 remaini for ( unsigned int i = 0; i < filesInThisCluster; ++i ) { MemoryCardFileEntry* entry = &entries->entries[i]; if ( entry->IsValid() && entry->IsUsed() && entry->IsDir() ) { - const u32 cluster = entry->entry.data.cluster; - if ( cluster > 0 ) { + if ( !entry->IsDotDir() ) { const wxString subDirName = wxString::FromAscii( (const char*)entry->entry.data.name ); const wxString subDirPath = dirPath + L"/" + subDirName; @@ -888,7 +887,7 @@ void FolderMemoryCard::FlushFileEntries( const u32 dirCluster, const u32 remaini MemoryCardFileMetadataReference* dirRef = AddDirEntryToMetadataQuickAccess( entry, parent ); - FlushFileEntries( cluster, entry->entry.data.length, subDirPath, dirRef ); + FlushFileEntries( entry->entry.data.cluster, entry->entry.data.length, subDirPath, dirRef ); } } else if ( entry->IsValid() && entry->IsUsed() && entry->IsFile() ) { AddFileEntryToMetadataQuickAccess( entry, parent ); diff --git a/pcsx2/gui/MemoryCardFolder.h b/pcsx2/gui/MemoryCardFolder.h index ba80018cc1..96e4bb338c 100644 --- a/pcsx2/gui/MemoryCardFolder.h +++ b/pcsx2/gui/MemoryCardFolder.h @@ -112,6 +112,8 @@ struct MemoryCardFileEntry { bool IsDir() { return !!( entry.data.mode & 0x0020 ); } bool IsUsed() { return !!( entry.data.mode & 0x8000 ); } bool IsValid() { return entry.data.mode != 0xFFFFFFFF; } + // checks if we're either "." or ".." + bool IsDotDir() { return entry.data.name[0] == '.' && ( entry.data.name[1] == '\0' || ( entry.data.name[1] == '.' && entry.data.name[2] == '\0' ) ); } static const u32 DefaultDirMode = 0x8427; static const u32 DefaultFileMode = 0x8497;