mirror of https://github.com/PCSX2/pcsx2.git
FolderMemoryCard: More robust way of checking validity of a subdirectory.
Fixes this memory card: http://forums.pcsx2.net/Thread-New-feature-Needs-testing-Automatically-managed-Folder-Memory-Card-Public-Test?pid=463506#pid463506 Presumably related to something LaunchElf writes into the memory card file entries.
This commit is contained in:
parent
50ad3a8bf5
commit
0976e124e8
|
@ -576,7 +576,7 @@ MemoryCardFileEntryCluster* FolderMemoryCard::GetFileEntryCluster( const u32 cur
|
|||
const u32 filesInThisCluster = std::min( fileCount, 2u );
|
||||
for ( unsigned int i = 0; i < filesInThisCluster; ++i ) {
|
||||
MemoryCardFileEntry* const entry = &it->second.entries[i];
|
||||
if ( entry->IsValid() && entry->IsUsed() && entry->IsDir() && entry->entry.data.cluster != 0 ) {
|
||||
if ( entry->IsValid() && entry->IsUsed() && entry->IsDir() && !entry->IsDotDir() ) {
|
||||
const u32 newFileCount = entry->entry.data.length;
|
||||
MemoryCardFileEntryCluster* ptr = GetFileEntryCluster( entry->entry.data.cluster, searchCluster, newFileCount );
|
||||
if ( ptr != nullptr ) { return ptr; }
|
||||
|
@ -618,7 +618,7 @@ MemoryCardFileEntry* FolderMemoryCard::GetFileEntryFromFileDataCluster( const u3
|
|||
// check subdirectories
|
||||
for ( int i = 0; i < 2; ++i ) {
|
||||
MemoryCardFileEntry* const entry = &m_fileEntryDict[currentCluster].entries[i];
|
||||
if ( entry->IsValid() && entry->IsUsed() && entry->IsDir() && entry->entry.data.cluster != 0 ) {
|
||||
if ( entry->IsValid() && entry->IsUsed() && entry->IsDir() && !entry->IsDotDir() ) {
|
||||
MemoryCardFileEntry* ptr = GetFileEntryFromFileDataCluster( entry->entry.data.cluster, searchCluster, fileName, originalDirCount, outClusterNumber );
|
||||
if ( ptr != nullptr ) {
|
||||
fileName->InsertDir( originalDirCount, wxString::FromAscii( (const char*)entry->entry.data.name ) );
|
||||
|
@ -863,8 +863,7 @@ void FolderMemoryCard::FlushFileEntries( const u32 dirCluster, const u32 remaini
|
|||
for ( unsigned int i = 0; i < filesInThisCluster; ++i ) {
|
||||
MemoryCardFileEntry* entry = &entries->entries[i];
|
||||
if ( entry->IsValid() && entry->IsUsed() && entry->IsDir() ) {
|
||||
const u32 cluster = entry->entry.data.cluster;
|
||||
if ( cluster > 0 ) {
|
||||
if ( !entry->IsDotDir() ) {
|
||||
const wxString subDirName = wxString::FromAscii( (const char*)entry->entry.data.name );
|
||||
const wxString subDirPath = dirPath + L"/" + subDirName;
|
||||
|
||||
|
@ -888,7 +887,7 @@ void FolderMemoryCard::FlushFileEntries( const u32 dirCluster, const u32 remaini
|
|||
|
||||
MemoryCardFileMetadataReference* dirRef = AddDirEntryToMetadataQuickAccess( entry, parent );
|
||||
|
||||
FlushFileEntries( 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() ) {
|
||||
AddFileEntryToMetadataQuickAccess( entry, parent );
|
||||
|
|
|
@ -112,6 +112,8 @@ struct MemoryCardFileEntry {
|
|||
bool IsDir() { return !!( entry.data.mode & 0x0020 ); }
|
||||
bool IsUsed() { return !!( entry.data.mode & 0x8000 ); }
|
||||
bool IsValid() { return entry.data.mode != 0xFFFFFFFF; }
|
||||
// checks if we're either "." or ".."
|
||||
bool IsDotDir() { return entry.data.name[0] == '.' && ( entry.data.name[1] == '\0' || ( entry.data.name[1] == '.' && entry.data.name[2] == '\0' ) ); }
|
||||
|
||||
static const u32 DefaultDirMode = 0x8427;
|
||||
static const u32 DefaultFileMode = 0x8497;
|
||||
|
|
Loading…
Reference in New Issue