From 52b7411ceebbf7b8c4d54cec91a3286637cf5b70 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Mon, 6 Feb 2006 02:58:34 +0000 Subject: [PATCH] PBXGetVolInfoSync is deprecated as is just about every other function that will convert from a path to a vol ref number so don't bother. Just use the volume name to flush since that was the only thing the vol ref number was used for. Compute volume size using block size times number of blocks. --- .../src/arch/MemoryCard/MemoryCardDriver.h | 2 - .../MemoryCardDriverThreaded_OSX.cpp | 48 ++++--------------- 2 files changed, 9 insertions(+), 41 deletions(-) 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") );