From c4570750ea3ef2b7336b47248332ada01c494fd6 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Mon, 29 Jun 2015 00:29:07 +0200 Subject: [PATCH] FolderMemoryCard: Put the initialization of the file entry flushing logic into its own method. --- pcsx2/gui/MemoryCardFolder.cpp | 17 +++++++++++------ pcsx2/gui/MemoryCardFolder.h | 3 +++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pcsx2/gui/MemoryCardFolder.cpp b/pcsx2/gui/MemoryCardFolder.cpp index 2bd996914c..7c13ed8a9d 100644 --- a/pcsx2/gui/MemoryCardFolder.cpp +++ b/pcsx2/gui/MemoryCardFolder.cpp @@ -813,12 +813,7 @@ void FolderMemoryCard::Flush() { } // then all directory and file entries - const u32 rootDirCluster = m_superBlock.data.rootdir_cluster; - FlushCluster( rootDirCluster + m_superBlock.data.alloc_offset ); - MemoryCardFileEntryCluster* rootEntries = &m_fileEntryDict[rootDirCluster]; - if ( rootEntries->entries[0].IsValid() && rootEntries->entries[0].IsUsed() ) { - FlushFileEntries( rootDirCluster, rootEntries->entries[0].entry.data.length ); - } + FlushFileEntries(); // and finally, flush everything that hasn't been flushed yet for ( uint i = 0; i < pageCount; ++i ) { @@ -852,6 +847,16 @@ void FolderMemoryCard::FlushBlock( const u32 block ) { } } +void FolderMemoryCard::FlushFileEntries() { + // Flush all file entry data from the cache into m_fileEntryDict. + const u32 rootDirCluster = m_superBlock.data.rootdir_cluster; + FlushCluster( rootDirCluster + m_superBlock.data.alloc_offset ); + MemoryCardFileEntryCluster* rootEntries = &m_fileEntryDict[rootDirCluster]; + if ( rootEntries->entries[0].IsValid() && rootEntries->entries[0].IsUsed() ) { + FlushFileEntries( rootDirCluster, rootEntries->entries[0].entry.data.length ); + } +} + void FolderMemoryCard::FlushFileEntries( const u32 dirCluster, const u32 remainingFiles, const wxString& dirPath, MemoryCardFileMetadataReference* parent ) { // flush the current cluster FlushCluster( dirCluster + m_superBlock.data.alloc_offset ); diff --git a/pcsx2/gui/MemoryCardFolder.h b/pcsx2/gui/MemoryCardFolder.h index 96e4bb338c..e30d20f9d9 100644 --- a/pcsx2/gui/MemoryCardFolder.h +++ b/pcsx2/gui/MemoryCardFolder.h @@ -381,6 +381,9 @@ protected: // flush a whole memory card block of the cache to the internal data and/or host file system void FlushBlock( const u32 block ); + // flush all directory and file entries to the internal data + void FlushFileEntries(); + // flush a directory's file entries and all its subdirectories to the internal data void FlushFileEntries( const u32 dirCluster, const u32 remainingFiles, const wxString& dirPath = L"", MemoryCardFileMetadataReference* parent = nullptr );