diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriver.h b/stepmania/src/arch/MemoryCard/MemoryCardDriver.h index 0cf915141d..5ad519c367 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriver.h +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriver.h @@ -11,7 +11,6 @@ struct UsbStorageDevice iBus = -1; iPort = -1; iLevel = -1; - iRefNum = -1; sDevice = ""; sSerial = ""; // be different than a card with no serial sOsMountDir = ""; @@ -28,7 +27,6 @@ struct UsbStorageDevice int iBus; int iPort; int iLevel; - int iRefNum; RString sSerial; RString sDevice; RString sOsMountDir; // WITHOUT trailing slash diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_OSX.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_OSX.cpp index ed551e3417..d99b7a3463 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_OSX.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_OSX.cpp @@ -44,15 +44,16 @@ MemoryCardDriverThreaded_OSX::~MemoryCardDriverThreaded_OSX() } void MemoryCardDriverThreaded_OSX::Unmount( UsbStorageDevice *pDevice ) -{ - if( pDevice->iRefNum == -1 ) - return; - +{ ParamBlockRec pb; + Str255 name; // A pascal string. + const RString& base = Basename( pDevice->sOsMountDir ); memset( &pb, 0, sizeof(pb) ); - pb.volumeParam.ioNamePtr = NULL; - pb.volumeParam.ioVRefNum = pDevice->iRefNum; + name[0] = min( base.length(), size_t(255) ); + strncpy( (char *)&name[1], base, name[0] ); + pb.volumeParam.ioNamePtr = name; + pb.volumeParam.ioVolIndex = -1; // Use ioNamePtr to find the volume. if( PBFlushVolSync(&pb) != noErr ) LOG->Warn( "Failed to flush the memory card." ); @@ -109,7 +110,6 @@ static RString GetStringProperty( io_registry_entry_t entry, CFStringRef key ) void MemoryCardDriverThreaded_OSX::GetUSBStorageDevices( vector& vDevicesOut ) { - LOG->Trace( "GetUSBStorageDevices." ); LockMut( m_ChangedLock ); // First, get all device paths struct statfs *fs; @@ -192,38 +192,8 @@ void MemoryCardDriverThreaded_OSX::GetUSBStorageDevices( vectorTrace( "Found memory card at path: %s.", fs[i].f_mntonname ); usbd.SetOsMountDir( fs[i].f_mntonname ); - - // Find volume reference number for flushing. - XVolumeParam param; - Str255 name; // A pascal string. - const RString& base = Basename( fs[i].f_mntonname ); - - memset( ¶m, 0, sizeof(param) ); - name[0] = min( base.length(), size_t(255) ); - strncpy( (char *)&name[1], base, name[0] ); - param.ioNamePtr = name; - param.ioVolIndex = -1; // Use ioNamePtr to find the volume. - - /* At this point, we have 3 methods available to get the volume size. - * we can use: - * param.ioVTotalBytes, - * IORegistryEntryCreateCFProperty( entry, CFSTR(kIOMediaSizeKey), NULL, 0 ), - * or fs[i].f_blocks * fs[i].f_bsize, however, we released entry already. */ - // XXX PBXGetVolInfoSync is apparently deprecated. - if( PBXGetVolInfoSync(¶m) == noErr ) - { - usbd.iRefNum = param.ioVRefNum; - usbd.iVolumeSizeMB = param.ioVTotalBytes >> 20; - } - else - { - /* We could fall back on one of the other methods but if we can't - * get the volume info then something is wrong so give up. */ - usbd.SetError( "Failed to get volume info." ); - IOObjectRelease( device ); - break; - } - + usbd.iVolumeSizeMB = (uint64_t(fs[i].f_blocks) * fs[i].f_bsize) >> 20; + // Now we can get some more information from the registry tree. usbd.iBus = GetIntProperty( device, CFSTR("USB Address") ); usbd.iPort = GetIntProperty( device, CFSTR("PortNum") );