From 9555d508eeb9fb265fe2e38002c2845fd1e4cac1 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 14 Mar 2004 01:40:24 +0000 Subject: [PATCH] move RageFileManager mounting into the MemoryCardDriver, not MemoryCardManager --- stepmania/src/MemoryCardManager.cpp | 8 +++++- stepmania/src/MemoryCardManager.h | 11 +++++++- stepmania/src/ProfileManager.cpp | 28 ++++--------------- .../src/arch/MemoryCard/MemoryCardDriver.h | 3 +- .../MemoryCard/MemoryCardDriver_Linux.cpp | 8 +++++- .../arch/MemoryCard/MemoryCardDriver_Linux.h | 2 +- .../arch/MemoryCard/MemoryCardDriver_Null.h | 2 +- .../MemoryCard/MemoryCardDriver_Windows.cpp | 9 +++++- .../MemoryCard/MemoryCardDriver_Windows.h | 2 +- 9 files changed, 41 insertions(+), 32 deletions(-) diff --git a/stepmania/src/MemoryCardManager.cpp b/stepmania/src/MemoryCardManager.cpp index b68d70cce0..52342cfe3a 100644 --- a/stepmania/src/MemoryCardManager.cpp +++ b/stepmania/src/MemoryCardManager.cpp @@ -126,6 +126,7 @@ MemoryCardState MemoryCardManager::GetCardState( PlayerNumber pn ) return MEMORY_CARD_STATE_READY; } +/* CString MemoryCardManager::GetOsMountDir( PlayerNumber pn ) { if( m_Device[pn].IsBlank() ) @@ -139,6 +140,7 @@ CString MemoryCardManager::GetOsMountDir( PlayerNumber pn ) return sDir; } } +*/ void MemoryCardManager::LockCards( bool bLock ) { @@ -230,8 +232,12 @@ match: m_bTooLate[p] = m_bCardsLocked; m_bWriteError[p] = false; if( !m_bCardsLocked ) - if( !m_pDriver->MountAndTestWrite(&m_Device[p]) ) + { + if( !m_pDriver->MountAndTestWrite(&m_Device[p], MEM_CARD_MOUNT_POINT[p]) ) + { m_bWriteError[p] = true; + } + } // play sound if( m_bWriteError[p] ) diff --git a/stepmania/src/MemoryCardManager.h b/stepmania/src/MemoryCardManager.h index f5a8956f58..86953212b6 100644 --- a/stepmania/src/MemoryCardManager.h +++ b/stepmania/src/MemoryCardManager.h @@ -15,6 +15,15 @@ #include "RageSound.h" #include "arch/MemoryCard/MemoryCardDriver.h" + +const CString MEM_CARD_MOUNT_POINT[NUM_PLAYERS] = +{ + /* @ is importast; see RageFileManager LoadedDriver::GetPath */ + "@mc1/", + "@mc2/", +}; + + class MemoryCardManager { public: @@ -25,7 +34,7 @@ public: MemoryCardState GetCardState( PlayerNumber pn ); - CString GetOsMountDir( PlayerNumber pn ); // only valid when state = ready +// CString GetOsMountDir( PlayerNumber pn ); // only valid when state = ready void LockCards( bool bLock ); // prevent removing or changing of memory cards diff --git a/stepmania/src/ProfileManager.cpp b/stepmania/src/ProfileManager.cpp index 7f0f52e526..91ce8b1a66 100644 --- a/stepmania/src/ProfileManager.cpp +++ b/stepmania/src/ProfileManager.cpp @@ -34,23 +34,11 @@ ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program - #define NEW_MEM_CARD_NAME "" - - #define USER_PROFILES_DIR "Data/LocalProfiles/" #define MACHINE_PROFILE_DIR "Data/MachineProfile/" - -static const char *MEM_CARD_DIR[NUM_PLAYERS] = -{ - /* @ is importast; see RageFileManager LoadedDriver::GetPath */ - "@mc1/", - "@mc2/", -}; - - ProfileManager::ProfileManager() { PROFILEMAN = this; @@ -144,19 +132,11 @@ bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn ) { UnloadProfile( pn ); #ifndef _XBOX - // moust slot + // mount slot if( MEMCARDMAN->GetCardState(pn) == MEMORY_CARD_STATE_READY ) { - // XXX: Remounting a different OS directory to the same mount point - // seems to be broken. Investigate this later... - FILEMAN->Mount( "dir", MEMCARDMAN->GetOsMountDir(pn), MEM_CARD_DIR[pn] ); - LOG->Trace( "mount %s %s", MEMCARDMAN->GetOsMountDir(pn).c_str(), MEM_CARD_DIR[pn] ); - CString sDir = MEM_CARD_DIR[pn]; + CString sDir = MEM_CARD_MOUNT_POINT[pn]; -// CString sDir = MEMCARDMAN->GetOsMountDir(pn); - - DEBUG_ASSERT( MEMCARDMAN->GetOsMountDir(pn) ); // should be called only if we've already mounted - // tack on a subdirectory so that we don't write everything to the root sDir += PREFSMAN->m_sMemoryCardProfileSubdir; sDir += '/'; @@ -179,7 +159,9 @@ bool ProfileManager::CreateMemoryCardProfile( PlayerNumber pn ) { // CString sDir = MEM_CARD_DIR[pn]; - CString sDir = MEMCARDMAN->GetOsMountDir(pn); + ASSERT( MEMCARDMAN->GetCardState(pn) == MEMORY_CARD_STATE_READY ); + + CString sDir = MEM_CARD_MOUNT_POINT[pn]; DEBUG_ASSERT( FILEMAN->IsMounted(sDir) ); // should be called only if we've already mounted diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriver.h b/stepmania/src/arch/MemoryCard/MemoryCardDriver.h index 453f7265cb..6cdda31784 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriver.h +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriver.h @@ -1,7 +1,6 @@ #ifndef MEMORY_CARD_ENUMERATOR_H #define MEMORY_CARD_ENUMERATOR_H 1 - struct UsbStorageDevice { UsbStorageDevice() { MakeBlank(); } @@ -44,7 +43,7 @@ public: virtual ~MemoryCardDriver() {}; virtual bool StorageDevicesChanged() = 0; virtual void GetStorageDevices( vector& vStorageDevicesOut ) = 0; - virtual bool MountAndTestWrite( UsbStorageDevice* pDevice ) = 0; // return false if mount or write fails + virtual bool MountAndTestWrite( UsbStorageDevice* pDevice, CString sMountPoint ) = 0; // return false if mount or write fails virtual void Flush( UsbStorageDevice* pDevice ) {} virtual void ResetUsbStorage() {}; }; diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Linux.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Linux.cpp index 265d61a002..b5b630cbc6 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Linux.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Linux.cpp @@ -231,7 +231,7 @@ void MemoryCardDriver_Linux::GetStorageDevices( vector& vDevic } } -bool MemoryCardDriver_Linux::MountAndTestWrite( UsbStorageDevice* pDevice ) +bool MemoryCardDriver_Linux::MountAndTestWrite( UsbStorageDevice* pDevice, CString sMountPoint ) { if( pDevice->sOsMountDir.empty() ) return false; @@ -255,6 +255,12 @@ bool MemoryCardDriver_Linux::MountAndTestWrite( UsbStorageDevice* pDevice ) fclose( fp ); remove( sFile ); + + // XXX: Remounting a different OS directory to the same mount point + // seems to be broken. Investigate this later... + FILEMAN->Mount( "dir", pDevice->sOsMountDir, sMountPoint.c_str() ); + LOG->Trace( "FILEMAN->Mount %s %s", pDevice->sOsMountDir.c_str(), sMountPoint.c_str() ); + return true; } diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Linux.h b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Linux.h index 6778dda2f4..3260bdb6dc 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Linux.h +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Linux.h @@ -10,7 +10,7 @@ public: virtual ~MemoryCardDriver_Linux(); virtual bool StorageDevicesChanged(); virtual void GetStorageDevices( vector& vStorageDevicesOut ); - virtual bool MountAndTestWrite( UsbStorageDevice* pDevice ); + virtual bool MountAndTestWrite( UsbStorageDevice* pDevice, CString sMountPoint ); virtual void Flush( UsbStorageDevice* pDevice ); virtual void ResetUsbStorage(); protected: diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Null.h b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Null.h index 69e3397dd1..243884a485 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Null.h +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Null.h @@ -9,7 +9,7 @@ public: MemoryCardDriver_Null() {}; virtual bool StorageDevicesChanged() { return false; }; virtual void GetStorageDevices( vector& vStorageDevicesOut ) {}; - virtual bool MountAndTestWrite( UsbStorageDevice* pDevice ) { return false; }; + virtual bool MountAndTestWrite( UsbStorageDevice* pDevice, CString sMountPoint ) { return false; }; virtual void Flush( UsbStorageDevice* pDevice ) {}; }; diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Windows.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Windows.cpp index 830abfac58..4c49f53fa5 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Windows.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Windows.cpp @@ -3,6 +3,8 @@ #include "RageUtil.h" #include #include +#include "RageFileManager.h" +#include "RageLog.h" MemoryCardDriver_Windows::MemoryCardDriver_Windows() { @@ -49,7 +51,7 @@ void MemoryCardDriver_Windows::GetStorageDevices( vector& vDev } } -bool MemoryCardDriver_Windows::MountAndTestWrite( UsbStorageDevice* pDevice ) +bool MemoryCardDriver_Windows::MountAndTestWrite( UsbStorageDevice* pDevice, CString sMountPoint ) { if( pDevice->sOsMountDir.empty() ) return false; @@ -81,6 +83,11 @@ bool MemoryCardDriver_Windows::MountAndTestWrite( UsbStorageDevice* pDevice ) fclose( fp ); remove( sFile ); + // XXX: Remounting a different OS directory to the same mount point + // seems to be broken. Investigate this later... + FILEMAN->Mount( "dir", pDevice->sOsMountDir, sMountPoint.c_str() ); + LOG->Trace( "FILEMAN->Mount %s %s", pDevice->sOsMountDir.c_str(), sMountPoint.c_str() ); + return true; } diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Windows.h b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Windows.h index 776ae09e45..bbbba7a0e4 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Windows.h +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Windows.h @@ -11,7 +11,7 @@ public: virtual ~MemoryCardDriver_Windows(); virtual bool StorageDevicesChanged(); virtual void GetStorageDevices( vector& vStorageDevicesOut ); - virtual bool MountAndTestWrite( UsbStorageDevice* pDevice ); + virtual bool MountAndTestWrite( UsbStorageDevice* pDevice, CString sMountPoint ); virtual void Flush( UsbStorageDevice* pDevice ); protected: DWORD m_dwLastLogicalDrives;