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 );
|
const u32 filesInThisCluster = std::min( remainingFiles, 2u );
|
||||||
for ( unsigned int i = 0; i < filesInThisCluster; ++i ) {
|
for ( unsigned int i = 0; i < filesInThisCluster; ++i ) {
|
||||||
MemoryCardFileEntry* entry = &entries->entries[i];
|
MemoryCardFileEntry* entry = &entries->entries[i];
|
||||||
if ( entry->IsValid() && entry->IsUsed() && entry->IsDir() ) {
|
if ( entry->IsValid() && entry->IsUsed() )
|
||||||
|
{
|
||||||
|
if ( entry->IsDir() )
|
||||||
|
{
|
||||||
if ( !entry->IsDotDir() ) {
|
if ( !entry->IsDotDir() ) {
|
||||||
char cleanName[sizeof( entry->entry.data.name )];
|
char cleanName[sizeof( entry->entry.data.name )];
|
||||||
memcpy( cleanName, (const char*)entry->entry.data.name, sizeof( cleanName ) );
|
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 );
|
FlushFileEntries( entry->entry.data.cluster, entry->entry.data.length, subDirPath, dirRef );
|
||||||
}
|
}
|
||||||
} else if ( entry->IsValid() && entry->IsUsed() && entry->IsFile() ) {
|
} else if ( entry->IsFile() ) {
|
||||||
AddFileEntryToMetadataQuickAccess( entry, parent );
|
const MemoryCardFileMetadataReference* fileRef = AddFileEntryToMetadataQuickAccess( entry, parent );
|
||||||
|
|
||||||
if ( entry->entry.data.length == 0 ) {
|
if ( entry->entry.data.length == 0 ) {
|
||||||
// empty files need to be explicitly created, as there will be no data cluster referencing it later
|
// 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 )];
|
char cleanName[sizeof( entry->entry.data.name )];
|
||||||
memcpy( cleanName, (const char*)entry->entry.data.name, sizeof( cleanName ) );
|
memcpy( cleanName, (const char*)entry->entry.data.name, sizeof( cleanName ) );
|
||||||
FileAccessHelper::CleanMemcardFilename( cleanName );
|
FileAccessHelper::CleanMemcardFilename( cleanName );
|
||||||
const wxString filePath = dirPath + L"/" + wxString::FromAscii( (const char*)cleanName );
|
const wxString filePath = dirPath + L"/" + wxString::FromAscii( (const char*)cleanName );
|
||||||
|
|
||||||
if ( m_performFileWrites ) {
|
|
||||||
wxFileName fn( m_folderName.GetFullPath() + filePath );
|
wxFileName fn( m_folderName.GetFullPath() + filePath );
|
||||||
|
|
||||||
if ( !fn.FileExists() ) {
|
if ( !fn.FileExists() ) {
|
||||||
if ( !fn.DirExists() ) {
|
if ( !fn.DirExists() ) {
|
||||||
fn.Mkdir( 0777, wxPATH_MKDIR_FULL );
|
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 ) {
|
if ( writeMetadata ) {
|
||||||
WriteMetadata( folderName, fileRef );
|
WriteMetadata( folderName, fileRef );
|
||||||
WriteIndex( folderName, fileRef );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
@ -1594,7 +1602,6 @@ wxFFile* FileAccessHelper::ReOpen( const wxFileName& folderName, MemoryCardFileM
|
||||||
if ( writeMetadata ) {
|
if ( writeMetadata ) {
|
||||||
if ( m_lastWrittenFileRef != fileRef ) {
|
if ( m_lastWrittenFileRef != fileRef ) {
|
||||||
WriteMetadata( folderName, fileRef );
|
WriteMetadata( folderName, fileRef );
|
||||||
WriteIndex( folderName, fileRef );
|
|
||||||
m_lastWrittenFileRef = fileRef;
|
m_lastWrittenFileRef = fileRef;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -246,6 +246,8 @@ public:
|
||||||
// returns true if any changes were made
|
// returns true if any changes were made
|
||||||
static bool CleanMemcardFilename( char* name );
|
static bool CleanMemcardFilename( char* name );
|
||||||
|
|
||||||
|
static void WriteIndex( wxFileName folderName, const MemoryCardFileMetadataReference* fileRef );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// helper function for CleanMemcardFilename()
|
// helper function for CleanMemcardFilename()
|
||||||
static bool CleanMemcardFilenameEndDotOrSpace( char* name, size_t length );
|
static bool CleanMemcardFilenameEndDotOrSpace( char* name, size_t length );
|
||||||
|
@ -257,7 +259,6 @@ private:
|
||||||
void CloseFileHandle( wxFFile* file, const MemoryCardFileEntry* entry = nullptr );
|
void CloseFileHandle( wxFFile* file, const MemoryCardFileEntry* entry = nullptr );
|
||||||
|
|
||||||
void WriteMetadata( wxFileName folderName, const MemoryCardFileMetadataReference* fileRef );
|
void WriteMetadata( wxFileName folderName, const MemoryCardFileMetadataReference* fileRef );
|
||||||
void WriteIndex( wxFileName folderName, const MemoryCardFileMetadataReference* fileRef );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue