mirror of https://github.com/PCSX2/pcsx2.git
Folder memcards: Write the file index from FlushFileEntries
Resolves issues with flushes being performed out of order, breaking the intended order of files in the file dictionary
This commit is contained in:
parent
f8f783737d
commit
c7ad748e98
|
@ -985,7 +985,10 @@ void FolderMemoryCard::FlushFileEntries( const u32 dirCluster, const u32 remaini
|
|||
const u32 filesInThisCluster = std::min( remainingFiles, 2u );
|
||||
for ( unsigned int i = 0; i < filesInThisCluster; ++i ) {
|
||||
MemoryCardFileEntry* entry = &entries->entries[i];
|
||||
if ( entry->IsValid() && entry->IsUsed() && entry->IsDir() ) {
|
||||
if ( entry->IsValid() && entry->IsUsed() )
|
||||
{
|
||||
if ( entry->IsDir() )
|
||||
{
|
||||
if ( !entry->IsDotDir() ) {
|
||||
char cleanName[sizeof( entry->entry.data.name )];
|
||||
memcpy( cleanName, (const char*)entry->entry.data.name, sizeof( cleanName ) );
|
||||
|
@ -1031,17 +1034,18 @@ void FolderMemoryCard::FlushFileEntries( const u32 dirCluster, const u32 remaini
|
|||
|
||||
FlushFileEntries( entry->entry.data.cluster, entry->entry.data.length, subDirPath, dirRef );
|
||||
}
|
||||
} else if ( entry->IsValid() && entry->IsUsed() && entry->IsFile() ) {
|
||||
AddFileEntryToMetadataQuickAccess( entry, parent );
|
||||
} else if ( entry->IsFile() ) {
|
||||
const MemoryCardFileMetadataReference* fileRef = AddFileEntryToMetadataQuickAccess( entry, parent );
|
||||
|
||||
if ( entry->entry.data.length == 0 ) {
|
||||
// empty files need to be explicitly created, as there will be no data cluster referencing it later
|
||||
if ( m_performFileWrites ) {
|
||||
char cleanName[sizeof( entry->entry.data.name )];
|
||||
memcpy( cleanName, (const char*)entry->entry.data.name, sizeof( cleanName ) );
|
||||
FileAccessHelper::CleanMemcardFilename( cleanName );
|
||||
const wxString filePath = dirPath + L"/" + wxString::FromAscii( (const char*)cleanName );
|
||||
|
||||
if ( m_performFileWrites ) {
|
||||
wxFileName fn( m_folderName.GetFullPath() + filePath );
|
||||
|
||||
if ( !fn.FileExists() ) {
|
||||
if ( !fn.DirExists() ) {
|
||||
fn.Mkdir( 0777, wxPATH_MKDIR_FULL );
|
||||
|
@ -1051,6 +1055,11 @@ void FolderMemoryCard::FlushFileEntries( const u32 dirCluster, const u32 remaini
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_performFileWrites ) {
|
||||
FileAccessHelper::WriteIndex( m_folderName.GetFullPath() + dirPath, fileRef );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1515,7 +1524,6 @@ wxFFile* FileAccessHelper::Open( const wxFileName& folderName, MemoryCardFileMet
|
|||
|
||||
if ( writeMetadata ) {
|
||||
WriteMetadata( folderName, fileRef );
|
||||
WriteIndex( folderName, fileRef );
|
||||
}
|
||||
|
||||
return file;
|
||||
|
@ -1594,7 +1602,6 @@ wxFFile* FileAccessHelper::ReOpen( const wxFileName& folderName, MemoryCardFileM
|
|||
if ( writeMetadata ) {
|
||||
if ( m_lastWrittenFileRef != fileRef ) {
|
||||
WriteMetadata( folderName, fileRef );
|
||||
WriteIndex( folderName, fileRef );
|
||||
m_lastWrittenFileRef = fileRef;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -246,6 +246,8 @@ public:
|
|||
// returns true if any changes were made
|
||||
static bool CleanMemcardFilename( char* name );
|
||||
|
||||
static void WriteIndex( wxFileName folderName, const MemoryCardFileMetadataReference* fileRef );
|
||||
|
||||
private:
|
||||
// helper function for CleanMemcardFilename()
|
||||
static bool CleanMemcardFilenameEndDotOrSpace( char* name, size_t length );
|
||||
|
@ -257,7 +259,6 @@ private:
|
|||
void CloseFileHandle( wxFFile* file, const MemoryCardFileEntry* entry = nullptr );
|
||||
|
||||
void WriteMetadata( wxFileName folderName, const MemoryCardFileMetadataReference* fileRef );
|
||||
void WriteIndex( wxFileName folderName, const MemoryCardFileMetadataReference* fileRef );
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue