simplify name update logic

This commit is contained in:
Chris Danford
2004-05-03 00:34:54 +00:00
parent d30a6fe77b
commit bfd7b1930c
7 changed files with 32 additions and 37 deletions
@@ -15,6 +15,7 @@ struct UsbStorageDevice
sScsiDevice = "";
sSerial = "";
sOsMountDir = "";
sName = "";
};
int iBus;
int iPort;
@@ -30,13 +31,14 @@ struct UsbStorageDevice
bool operator==(const UsbStorageDevice& other) const
{
if( (iBus!=-1 || other.iBus!=-1) && iBus != other.iBus )
return false;
if( (iPort!=-1 || other.iPort!=-1) && iPort != other.iPort )
return false;
if( (iLevel!=-1 || other.iLevel!=-1) && iLevel != other.iLevel )
return false;
return sOsMountDir==other.sOsMountDir; // every time a device is plugged in, it gets a unique device number
#define COMPARE(x) if( x != other.x ) return false;
COMPARE( iBus );
COMPARE( iPort );
COMPARE( iLevel );
COMPARE( sName );
COMPARE( sOsMountDir );
return true;
#undef COMPARE
}
bool operator!=(const UsbStorageDevice& other) const
{
@@ -14,6 +14,8 @@ const CString TEMP_MOUNT_POINT = "@mctemp/";
MemoryCardDriverThreaded_Windows::MemoryCardDriverThreaded_Windows()
{
m_bReset = false;
StartThread();
}
@@ -59,6 +61,12 @@ void MemoryCardDriverThreaded_Windows::MountThreadMain()
while( !m_bShutdown )
{
if( m_bReset )
{
dwLastLogicalDrives = 0;
m_bReset = false;
}
DWORD dwNewLogicalDrives = ::GetLogicalDrives();
if( dwNewLogicalDrives != dwLastLogicalDrives )
{
@@ -141,6 +149,11 @@ void MemoryCardDriverThreaded_Windows::Flush( UsbStorageDevice* pDevice )
// Windows flushes automatically every ~2 seconds. -Chris
}
void MemoryCardDriverThreaded_Windows::ResetUsbStorage()
{
m_bReset = true;
}
/*
* Copyright (c) 2003 by the person(s) listed below. All rights reserved.
* Chris Danford
@@ -10,10 +10,12 @@ public:
virtual void Unmount( UsbStorageDevice* pDevice, CString sMountPoint );
virtual void Flush( UsbStorageDevice* pDevice );
virtual void ResetUsbStorage() {}
virtual void ResetUsbStorage();
protected:
virtual void MountThreadMain();
virtual void Mount( UsbStorageDevice* pDevice, CString sMountPoint );
bool m_bReset;
};
#endif