FolderMemoryCard: Put the initialization of the file entry flushing logic into its own method.

This commit is contained in:
Admiral H. Curtiss 2015-06-29 00:29:07 +02:00
parent fbc8d30b67
commit c4570750ea
2 changed files with 14 additions and 6 deletions

View File

@ -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 );

View File

@ -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 );