mirror of https://github.com/PCSX2/pcsx2.git
Folder memcards: Properly handle zero sized files when writing the memcard index
fileRef is nullptr for zero sized files
This commit is contained in:
parent
19af887257
commit
52408145c1
|
@ -1035,7 +1035,7 @@ 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->IsFile() ) {
|
} else if ( entry->IsFile() ) {
|
||||||
const MemoryCardFileMetadataReference* fileRef = AddFileEntryToMetadataQuickAccess( entry, parent );
|
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
|
||||||
|
@ -1057,7 +1057,7 @@ void FolderMemoryCard::FlushFileEntries( const u32 dirCluster, const u32 remaini
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_performFileWrites ) {
|
if ( m_performFileWrites ) {
|
||||||
FileAccessHelper::WriteIndex( m_folderName.GetFullPath() + dirPath, fileRef );
|
FileAccessHelper::WriteIndex( m_folderName.GetFullPath() + dirPath, entry, parent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1570,9 +1570,18 @@ void FileAccessHelper::WriteMetadata( wxFileName folderName, const MemoryCardFil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileAccessHelper::WriteIndex( wxFileName folderName, const MemoryCardFileMetadataReference* fileRef )
|
void FileAccessHelper::WriteIndex( wxFileName folderName, MemoryCardFileEntry* const entry, MemoryCardFileMetadataReference* const parent )
|
||||||
{
|
{
|
||||||
fileRef->GetPath( &folderName );
|
parent->GetPath( &folderName );
|
||||||
|
char cleanName[sizeof( entry->entry.data.name )];
|
||||||
|
memcpy( cleanName, (const char*)entry->entry.data.name, sizeof( cleanName ) );
|
||||||
|
bool localCleaned = FileAccessHelper::CleanMemcardFilename( cleanName );
|
||||||
|
|
||||||
|
if ( entry->IsDir() ) {
|
||||||
|
folderName.AppendDir( wxString::FromAscii( cleanName ) );
|
||||||
|
} else if ( entry->IsFile() ) {
|
||||||
|
folderName.SetName( wxString::FromAscii( cleanName ) );
|
||||||
|
}
|
||||||
|
|
||||||
const wxCharTypeBuffer fileName( folderName.GetName().ToUTF8() );
|
const wxCharTypeBuffer fileName( folderName.GetName().ToUTF8() );
|
||||||
folderName.SetName( L"_pcsx2_index" );
|
folderName.SetName( L"_pcsx2_index" );
|
||||||
|
@ -1591,9 +1600,9 @@ void FileAccessHelper::WriteIndex( wxFileName folderName, const MemoryCardFileMe
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update timestamps basing on internal data
|
// Update timestamps basing on internal data
|
||||||
const auto* entry = &fileRef->entry->entry.data;
|
const auto* e = &entry->entry.data;
|
||||||
entryNode["timeCreated"] = entry->timeCreated.ToTime();
|
entryNode["timeCreated"] = e->timeCreated.ToTime();
|
||||||
entryNode["timeModified"] = entry->timeModified.ToTime();
|
entryNode["timeModified"] = e->timeModified.ToTime();
|
||||||
|
|
||||||
// Write out the changes
|
// Write out the changes
|
||||||
wxFFile indexFile;
|
wxFFile indexFile;
|
||||||
|
|
|
@ -246,7 +246,7 @@ 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 );
|
static void WriteIndex( wxFileName folderName, MemoryCardFileEntry* const entry, MemoryCardFileMetadataReference* const parent );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// helper function for CleanMemcardFilename()
|
// helper function for CleanMemcardFilename()
|
||||||
|
|
Loading…
Reference in New Issue