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:
@@ -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,22 +74,25 @@ 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;
|
||||||
UsbStorageDeviceEx usbd;
|
|
||||||
usbd.sOsMountDir = sDrive;
|
|
||||||
usbd.bWriteTestSucceeded = TestWrite( sDrive );
|
|
||||||
|
|
||||||
// read name
|
if( !TestReady(sDrive) )
|
||||||
this->Mount( &usbd, TEMP_MOUNT_POINT );
|
continue;
|
||||||
FILEMAN->FlushDirCache( TEMP_MOUNT_POINT );
|
|
||||||
Profile profile;
|
|
||||||
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
|
|
||||||
profile.LoadEditableDataFromDir( sProfileDir );
|
|
||||||
usbd.sName = profile.GetDisplayName();
|
|
||||||
|
|
||||||
vNewStorageDevices.push_back( usbd );
|
UsbStorageDeviceEx usbd;
|
||||||
}
|
usbd.sOsMountDir = sDrive;
|
||||||
|
usbd.bWriteTestSucceeded = TestWrite( sDrive );
|
||||||
|
|
||||||
|
// read name
|
||||||
|
this->Mount( &usbd, TEMP_MOUNT_POINT );
|
||||||
|
FILEMAN->FlushDirCache( TEMP_MOUNT_POINT );
|
||||||
|
Profile profile;
|
||||||
|
CString sProfileDir = TEMP_MOUNT_POINT + PREFSMAN->m_sMemoryCardProfileSubdir + '/';
|
||||||
|
profile.LoadEditableDataFromDir( sProfileDir );
|
||||||
|
usbd.sName = profile.GetDisplayName();
|
||||||
|
|
||||||
|
vNewStorageDevices.push_back( usbd );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user