From 3a9ce7be4dda419c77a743279a57263de5b4096d Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 9 Nov 2003 11:50:28 +0000 Subject: [PATCH] fix Windows prompts to insert disk if memory card not present --- stepmania/src/PrefsManager.cpp | 2 ++ stepmania/src/PrefsManager.h | 1 + stepmania/src/ProfileManager.cpp | 24 ++++++++++++++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index 36d6a74195..f7cf5260fa 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -317,6 +317,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk() ini.GetValue( "Options", ssprintf("DefaultMachineProfileIDP%d",p+1), m_sDefaultMachineProfileID[p] ); ini.GetValue( "Options", ssprintf("MemoryCardDirP%d",p+1), m_sMemoryCardDir[p] ); FixSlashesInPlace( m_sMemoryCardDir[p] ); + ini.GetValue( "Options", ssprintf("MemoryCardMountCommandP%d",p+1), m_sMemoryCardMountCommand[p] ); } ini.GetValue( "Options", "CenterImageTranslateX", m_iCenterImageTranslateX ); @@ -453,6 +454,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const { ini.SetValue( "Options", ssprintf("DefaultMachineProfileIDP%d",p+1), m_sDefaultMachineProfileID[p] ); ini.SetValue( "Options", ssprintf("MemoryCardDirP%d",p+1), m_sMemoryCardDir[p] ); + ini.SetValue( "Options", ssprintf("MemoryCardMountCommandP%d",p+1), m_sMemoryCardMountCommand[p] ); } ini.SetValue( "Options", "CenterImageTranslateX", m_iCenterImageTranslateX ); diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index 85e4ab62e1..b9f8c5c486 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -108,6 +108,7 @@ public: CString m_sLanguage; CString m_sDefaultMachineProfileID[NUM_PLAYERS]; CString m_sMemoryCardDir[NUM_PLAYERS]; + CString m_sMemoryCardMountCommand[NUM_PLAYERS]; int m_iCenterImageTranslateX; int m_iCenterImageTranslateY; float m_fCenterImageScaleX; diff --git a/stepmania/src/ProfileManager.cpp b/stepmania/src/ProfileManager.cpp index 7007b3eb4a..f5dff57adc 100644 --- a/stepmania/src/ProfileManager.cpp +++ b/stepmania/src/ProfileManager.cpp @@ -163,9 +163,25 @@ bool ProfileManager::IsMemoryCardInserted( PlayerNumber pn ) sizeof(szFileSystemNameBuffer) ); return !!bResult; } -#endif +#else - return true; + // Try to create directory before writing a temp file. + CreateDirectories( sDir ); + + // Test whether a memory card is usable by trying to write a file. + CString sFile = sDir + "temp"; + FILE* fp = fopen( sFile, "w" ); + if( fp ) + { + fclose( fp ); + remove( sFile ); + return true; + } + else + { + return false; + } +#endif } bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn ) @@ -182,6 +198,10 @@ bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn ) bool ProfileManager::LoadFirstAvailableProfile( PlayerNumber pn ) { + // mount card + if( !PREFSMAN->m_sMemoryCardMountCommand[pn].empty() ) + system( PREFSMAN->m_sMemoryCardMountCommand[pn] ); + if( IsMemoryCardInserted(pn) ) { if( LoadProfileFromMemoryCard(pn) )