If a drive isn't ready, don't try to mount it at all; it may cause mkdir()

calls to be made (if eg. mounting "D:\foo"), causing "volume not ready"
dialogs.  This happens with removable devices like memory card readers
that don't have a device.

I think this is generally incorrect: if a user has a memcard reader, we'll ignore
it on the first change (no device is installed), and then we'll never actually
notice when a card is inserted, since the drive letters don't actually
change.  I don't have a memcard reader to test this, so I'm punting on
this for now.
This commit is contained in:
Glenn Maynard
2004-05-01 01:26:38 +00:00
parent 07fa62c417
commit 50b593f7d2
@@ -19,7 +19,7 @@ MemoryCardDriverThreaded_Windows::MemoryCardDriverThreaded_Windows()
typedef const CString& CCStringRef; typedef const CString& CCStringRef;
bool TestWrite( CCStringRef sDrive ) static bool TestReady( CCStringRef sDrive )
{ {
// TODO: Use RageFileDirect here to detect ready state? // TODO: Use RageFileDirect here to detect ready state?
TCHAR szVolumeNameBuffer[MAX_PATH]; TCHAR szVolumeNameBuffer[MAX_PATH];
@@ -27,7 +27,8 @@ bool TestWrite( CCStringRef sDrive )
DWORD dwMaximumComponentLength; DWORD dwMaximumComponentLength;
DWORD lpFileSystemFlags; DWORD lpFileSystemFlags;
TCHAR szFileSystemNameBuffer[MAX_PATH]; TCHAR szFileSystemNameBuffer[MAX_PATH];
BOOL bReady = GetVolumeInformation(
return !!GetVolumeInformation(
sDrive, sDrive,
szVolumeNameBuffer, szVolumeNameBuffer,
sizeof(szVolumeNameBuffer), sizeof(szVolumeNameBuffer),
@@ -36,9 +37,10 @@ bool TestWrite( CCStringRef sDrive )
&lpFileSystemFlags, &lpFileSystemFlags,
szFileSystemNameBuffer, szFileSystemNameBuffer,
sizeof(szFileSystemNameBuffer) ); sizeof(szFileSystemNameBuffer) );
if( !bReady ) }
return false;
static bool TestWrite( CCStringRef sDrive )
{
// Try to write a file. // Try to write a file.
// TODO: Can we use RageFile for this? // TODO: Can we use RageFile for this?
CString sFile = sDrive + "temp"; CString sFile = sDrive + "temp";
@@ -72,8 +74,12 @@ void MemoryCardDriverThreaded_Windows::MountThreadMain()
LOG->Trace( "Found drive %s", sDrive.c_str() ); LOG->Trace( "Found drive %s", sDrive.c_str() );
if( GetDriveType(sDrive) == DRIVE_REMOVABLE ) // is a removable drive if( GetDriveType(sDrive) != DRIVE_REMOVABLE ) // is a removable drive
{ continue;
if( !TestReady(sDrive) )
continue;
UsbStorageDeviceEx usbd; UsbStorageDeviceEx usbd;
usbd.sOsMountDir = sDrive; usbd.sOsMountDir = sDrive;
usbd.bWriteTestSucceeded = TestWrite( sDrive ); usbd.bWriteTestSucceeded = TestWrite( sDrive );
@@ -89,7 +95,6 @@ void MemoryCardDriverThreaded_Windows::MountThreadMain()
vNewStorageDevices.push_back( usbd ); vNewStorageDevices.push_back( usbd );
} }
} }
}
{ {
LockMut( m_mutexStorageDevices ); LockMut( m_mutexStorageDevices );