From 50b593f7d205f749e16eceff9d759a8d9945e632 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 1 May 2004 01:26:38 +0000 Subject: [PATCH] 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. --- .../MemoryCardDriverThreaded_Windows.cpp | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Windows.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Windows.cpp index d0295f41f9..22cba65312 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Windows.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Windows.cpp @@ -19,7 +19,7 @@ MemoryCardDriverThreaded_Windows::MemoryCardDriverThreaded_Windows() typedef const CString& CCStringRef; -bool TestWrite( CCStringRef sDrive ) +static bool TestReady( CCStringRef sDrive ) { // TODO: Use RageFileDirect here to detect ready state? TCHAR szVolumeNameBuffer[MAX_PATH]; @@ -27,7 +27,8 @@ bool TestWrite( CCStringRef sDrive ) DWORD dwMaximumComponentLength; DWORD lpFileSystemFlags; TCHAR szFileSystemNameBuffer[MAX_PATH]; - BOOL bReady = GetVolumeInformation( + + return !!GetVolumeInformation( sDrive, szVolumeNameBuffer, sizeof(szVolumeNameBuffer), @@ -36,9 +37,10 @@ bool TestWrite( CCStringRef sDrive ) &lpFileSystemFlags, szFileSystemNameBuffer, sizeof(szFileSystemNameBuffer) ); - if( !bReady ) - return false; +} +static bool TestWrite( CCStringRef sDrive ) +{ // Try to write a file. // TODO: Can we use RageFile for this? CString sFile = sDrive + "temp"; @@ -72,22 +74,25 @@ void MemoryCardDriverThreaded_Windows::MountThreadMain() LOG->Trace( "Found drive %s", sDrive.c_str() ); - if( GetDriveType(sDrive) == DRIVE_REMOVABLE ) // is a removable drive - { - UsbStorageDeviceEx usbd; - usbd.sOsMountDir = sDrive; - usbd.bWriteTestSucceeded = TestWrite( sDrive ); + if( GetDriveType(sDrive) != DRIVE_REMOVABLE ) // is a removable drive + continue; - // 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(); + if( !TestReady(sDrive) ) + continue; - 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 ); } }