break out MemoryCardDriverThreaded_Windows::GetUSBStorageDevices

This commit is contained in:
Glenn Maynard
2005-12-10 01:24:11 +00:00
parent 908e60fc0a
commit e94119a957
2 changed files with 65 additions and 66 deletions
@@ -75,26 +75,14 @@ static bool IsFloppyDrive( char c )
return false;
}
bool MemoryCardDriverThreaded_Windows::DoOneUpdate( bool bMount, vector<UsbStorageDevice>& vStorageDevicesOut )
void MemoryCardDriverThreaded_Windows::GetUSBStorageDevices( vector<UsbStorageDevice>& vDevicesOut )
{
DWORD dwNewLogicalDrives = ::GetLogicalDrives();
if( dwNewLogicalDrives == m_dwLastLogicalDrives )
{
// no change from last update
return false;
}
m_dwLastLogicalDrives = dwNewLogicalDrives;
{
vector<UsbStorageDevice> vNewStorageDevices;
const int MAX_DRIVES = 26;
CString sDrives;
for( int i=0; i<MAX_DRIVES; ++i )
{
DWORD mask = (1 << i);
if( !(dwNewLogicalDrives & mask) )
if( !(m_dwLastLogicalDrives & mask) )
continue; // drive letter is invalid
if( IsFloppyDrive(i+'a') )
continue;
@@ -111,8 +99,8 @@ bool MemoryCardDriverThreaded_Windows::DoOneUpdate( bool bMount, vector<UsbStora
if( !TestReady(sDrive, sVolumeLabel) )
continue;
vNewStorageDevices.push_back( UsbStorageDevice() );
UsbStorageDevice &usbd = vNewStorageDevices.back();
vDevicesOut.push_back( UsbStorageDevice() );
UsbStorageDevice &usbd = vDevicesOut.back();
usbd.SetOsMountDir( sDrive );
usbd.sVolumeLabel = sVolumeLabel;
if( TestWrite(sDrive) )
@@ -146,13 +134,22 @@ bool MemoryCardDriverThreaded_Windows::DoOneUpdate( bool bMount, vector<UsbStora
FILEMAN->Unmount( "dir", usbd.sOsMountDir, TEMP_MOUNT_POINT_INTERNAL );
}
CHECKPOINT;
vStorageDevicesOut = vNewStorageDevices;
CHECKPOINT;
LOG->Trace( "Found drives: %s", sDrives.c_str() );
}
bool MemoryCardDriverThreaded_Windows::DoOneUpdate( bool bMount, vector<UsbStorageDevice>& vStorageDevicesOut )
{
DWORD dwNewLogicalDrives = ::GetLogicalDrives();
if( dwNewLogicalDrives == m_dwLastLogicalDrives )
{
// no change from last update
return false;
}
m_dwLastLogicalDrives = dwNewLogicalDrives;
GetUSBStorageDevices( vStorageDevicesOut );
return true;
}
@@ -17,6 +17,8 @@ public:
virtual void Reset();
private:
void GetUSBStorageDevices( vector<UsbStorageDevice>& vDevicesOut );
DWORD m_dwLastLogicalDrives;
};