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; 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; const int MAX_DRIVES = 26;
CString sDrives; CString sDrives;
for( int i=0; i<MAX_DRIVES; ++i ) for( int i=0; i<MAX_DRIVES; ++i )
{ {
DWORD mask = (1 << i); DWORD mask = (1 << i);
if( !(dwNewLogicalDrives & mask) ) if( !(m_dwLastLogicalDrives & mask) )
continue; // drive letter is invalid continue; // drive letter is invalid
if( IsFloppyDrive(i+'a') ) if( IsFloppyDrive(i+'a') )
continue; continue;
@@ -111,8 +99,8 @@ bool MemoryCardDriverThreaded_Windows::DoOneUpdate( bool bMount, vector<UsbStora
if( !TestReady(sDrive, sVolumeLabel) ) if( !TestReady(sDrive, sVolumeLabel) )
continue; continue;
vNewStorageDevices.push_back( UsbStorageDevice() ); vDevicesOut.push_back( UsbStorageDevice() );
UsbStorageDevice &usbd = vNewStorageDevices.back(); UsbStorageDevice &usbd = vDevicesOut.back();
usbd.SetOsMountDir( sDrive ); usbd.SetOsMountDir( sDrive );
usbd.sVolumeLabel = sVolumeLabel; usbd.sVolumeLabel = sVolumeLabel;
if( TestWrite(sDrive) ) if( TestWrite(sDrive) )
@@ -146,13 +134,22 @@ bool MemoryCardDriverThreaded_Windows::DoOneUpdate( bool bMount, vector<UsbStora
FILEMAN->Unmount( "dir", usbd.sOsMountDir, TEMP_MOUNT_POINT_INTERNAL ); FILEMAN->Unmount( "dir", usbd.sOsMountDir, TEMP_MOUNT_POINT_INTERNAL );
} }
CHECKPOINT;
vStorageDevicesOut = vNewStorageDevices;
CHECKPOINT;
LOG->Trace( "Found drives: %s", sDrives.c_str() ); 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; return true;
} }
@@ -17,6 +17,8 @@ public:
virtual void Reset(); virtual void Reset();
private: private:
void GetUSBStorageDevices( vector<UsbStorageDevice>& vDevicesOut );
DWORD m_dwLastLogicalDrives; DWORD m_dwLastLogicalDrives;
}; };