refactor common unmount code
This commit is contained in:
@@ -135,6 +135,21 @@ bool MemoryCardDriverThreaded::MountAndTestWrite( UsbStorageDevice* pDevice, CSt
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MemoryCardDriverThreaded::UnmountMountPoint( const CString &sMountPoint )
|
||||||
|
{
|
||||||
|
vector<RageFileManager::DriverLocation> Mounts;
|
||||||
|
FILEMAN->GetLoadedDrivers( Mounts );
|
||||||
|
for( unsigned i = 0; i < Mounts.size(); ++i )
|
||||||
|
{
|
||||||
|
if( Mounts[i].Type.CompareNoCase( "dir" ) )
|
||||||
|
continue; // wrong type
|
||||||
|
if( Mounts[i].MountPoint.CompareNoCase( sMountPoint ) )
|
||||||
|
continue; // wrong mount point
|
||||||
|
FILEMAN->Unmount( Mounts[i].Type, Mounts[i].Root, Mounts[i].MountPoint );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003-2004 Chris Danford
|
* (c) 2003-2004 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ protected:
|
|||||||
bool m_bStorageDevicesChanged;
|
bool m_bStorageDevicesChanged;
|
||||||
RageMutex m_mutexStorageDevices; // protects the above two
|
RageMutex m_mutexStorageDevices; // protects the above two
|
||||||
bool m_bForceRedetectNextUpdate; // on the next update, redetect from scratch report new devices found
|
bool m_bForceRedetectNextUpdate; // on the next update, redetect from scratch report new devices found
|
||||||
|
|
||||||
|
|
||||||
|
// placed here for use by derivitives to eliminate duplicate code
|
||||||
|
void UnmountMountPoint( const CString &sMountPoint );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -276,6 +276,7 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
|
|||||||
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
|
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
|
||||||
profile.LoadEditableDataFromDir( sProfileDir );
|
profile.LoadEditableDataFromDir( sProfileDir );
|
||||||
d.sName = profile.GetDisplayName();
|
d.sName = profile.GetDisplayName();
|
||||||
|
UnmountMountPoint( TEMP_MOUNT_POINT );
|
||||||
|
|
||||||
LOG->Trace( "write test %s", d.bWriteTestSucceeded ? "succeeded" : "failed" );
|
LOG->Trace( "write test %s", d.bWriteTestSucceeded ? "succeeded" : "failed" );
|
||||||
}
|
}
|
||||||
@@ -645,17 +646,7 @@ void MemoryCardDriverThreaded_Linux::Mount( UsbStorageDevice* pDevice, CString s
|
|||||||
{
|
{
|
||||||
ASSERT( !pDevice->sOsMountDir.empty() );
|
ASSERT( !pDevice->sOsMountDir.empty() );
|
||||||
|
|
||||||
/* Unmount any previous mounts for this mountpoint. */
|
UnmountMountPoint( sMountPoint );
|
||||||
vector<RageFileManager::DriverLocation> Mounts;
|
|
||||||
FILEMAN->GetLoadedDrivers( Mounts );
|
|
||||||
for( unsigned i = 0; i < Mounts.size(); ++i )
|
|
||||||
{
|
|
||||||
if( Mounts[i].Type.CompareNoCase( "dir" ) )
|
|
||||||
continue; // wrong type
|
|
||||||
if( Mounts[i].MountPoint.CompareNoCase( sMountPoint ) )
|
|
||||||
continue; // wrong mount point
|
|
||||||
FILEMAN->Unmount( Mounts[i].Type, Mounts[i].Root, Mounts[i].MountPoint );
|
|
||||||
}
|
|
||||||
|
|
||||||
FILEMAN->Mount( "dir", pDevice->sOsMountDir, sMountPoint.c_str() );
|
FILEMAN->Mount( "dir", pDevice->sOsMountDir, sMountPoint.c_str() );
|
||||||
LOG->Trace( "FILEMAN->Mount %s %s", pDevice->sOsMountDir.c_str(), sMountPoint.c_str() );
|
LOG->Trace( "FILEMAN->Mount %s %s", pDevice->sOsMountDir.c_str(), sMountPoint.c_str() );
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ void MemoryCardDriverThreaded_Windows::MountThreadDoOneUpdate()
|
|||||||
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
|
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
|
||||||
profile.LoadEditableDataFromDir( sProfileDir );
|
profile.LoadEditableDataFromDir( sProfileDir );
|
||||||
usbd.sName = profile.GetDisplayName();
|
usbd.sName = profile.GetDisplayName();
|
||||||
|
UnmountMountPoint( TEMP_MOUNT_POINT );
|
||||||
}
|
}
|
||||||
|
|
||||||
vNewStorageDevices.push_back( usbd );
|
vNewStorageDevices.push_back( usbd );
|
||||||
@@ -136,17 +137,7 @@ void MemoryCardDriverThreaded_Windows::Mount( UsbStorageDevice* pDevice, CString
|
|||||||
{
|
{
|
||||||
ASSERT( !pDevice->sOsMountDir.empty() );
|
ASSERT( !pDevice->sOsMountDir.empty() );
|
||||||
|
|
||||||
/* Unmount any previous mounts for this mountpoint. */
|
UnmountMountPoint( sMountPoint );
|
||||||
vector<RageFileManager::DriverLocation> Mounts;
|
|
||||||
FILEMAN->GetLoadedDrivers( Mounts );
|
|
||||||
for( unsigned i = 0; i < Mounts.size(); ++i )
|
|
||||||
{
|
|
||||||
if( Mounts[i].Type.CompareNoCase( "dir" ) )
|
|
||||||
continue; // wrong type
|
|
||||||
if( Mounts[i].MountPoint.CompareNoCase( sMountPoint ) )
|
|
||||||
continue; // wrong mount point
|
|
||||||
FILEMAN->Unmount( Mounts[i].Type, Mounts[i].Root, Mounts[i].MountPoint );
|
|
||||||
}
|
|
||||||
|
|
||||||
FILEMAN->Mount( "dir", pDevice->sOsMountDir, sMountPoint.c_str() );
|
FILEMAN->Mount( "dir", pDevice->sOsMountDir, sMountPoint.c_str() );
|
||||||
LOG->Trace( "FILEMAN->Mount %s %s", pDevice->sOsMountDir.c_str(), sMountPoint.c_str() );
|
LOG->Trace( "FILEMAN->Mount %s %s", pDevice->sOsMountDir.c_str(), sMountPoint.c_str() );
|
||||||
|
|||||||
Reference in New Issue
Block a user