move RageFileManager mounting into the MemoryCardDriver, not MemoryCardManager
This commit is contained in:
@@ -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] )
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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<UsbStorageDevice>& 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() {};
|
||||
};
|
||||
|
||||
@@ -231,7 +231,7 @@ void MemoryCardDriver_Linux::GetStorageDevices( vector<UsbStorageDevice>& 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
virtual ~MemoryCardDriver_Linux();
|
||||
virtual bool StorageDevicesChanged();
|
||||
virtual void GetStorageDevices( vector<UsbStorageDevice>& vStorageDevicesOut );
|
||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice );
|
||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice, CString sMountPoint );
|
||||
virtual void Flush( UsbStorageDevice* pDevice );
|
||||
virtual void ResetUsbStorage();
|
||||
protected:
|
||||
|
||||
@@ -9,7 +9,7 @@ public:
|
||||
MemoryCardDriver_Null() {};
|
||||
virtual bool StorageDevicesChanged() { return false; };
|
||||
virtual void GetStorageDevices( vector<UsbStorageDevice>& vStorageDevicesOut ) {};
|
||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice ) { return false; };
|
||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice, CString sMountPoint ) { return false; };
|
||||
virtual void Flush( UsbStorageDevice* pDevice ) {};
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "RageUtil.h"
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include "RageFileManager.h"
|
||||
#include "RageLog.h"
|
||||
|
||||
MemoryCardDriver_Windows::MemoryCardDriver_Windows()
|
||||
{
|
||||
@@ -49,7 +51,7 @@ void MemoryCardDriver_Windows::GetStorageDevices( vector<UsbStorageDevice>& 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
virtual ~MemoryCardDriver_Windows();
|
||||
virtual bool StorageDevicesChanged();
|
||||
virtual void GetStorageDevices( vector<UsbStorageDevice>& vStorageDevicesOut );
|
||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice );
|
||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice, CString sMountPoint );
|
||||
virtual void Flush( UsbStorageDevice* pDevice );
|
||||
protected:
|
||||
DWORD m_dwLastLogicalDrives;
|
||||
|
||||
Reference in New Issue
Block a user