Preserves backwards compatibility with 10.6

sync_volume_np was introduced in the 10.8 SDK. This commit ensures that
some related constants are defined before calling the function. If they
are not, we fallback to the older logic.
This commit is contained in:
Jonathan Berney
2014-10-30 14:36:10 -07:00
parent e684e9668d
commit 4c7c64de62
@@ -60,8 +60,25 @@ MemoryCardDriverThreaded_MacOSX::~MemoryCardDriverThreaded_MacOSX()
void MemoryCardDriverThreaded_MacOSX::Unmount( UsbStorageDevice *pDevice )
{
#if defined(SYNC_VOLUME_FULLSYNC) && defined(SYNC_VOLUME_WAIT)
if( sync_volume_np( pDevice->sOsMountDir.c_str(), SYNC_VOLUME_FULLSYNC | SYNC_VOLUME_WAIT ) != 0 )
LOG->Warn( "Failed to flush the memory card." );
#else
ParamBlockRec pb;
Str255 name; // A pascal string.
const RString& base = Basename( pDevice->sOsMountDir );
memset( &pb, 0, sizeof(pb) );
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." );
#endif
}
bool MemoryCardDriverThreaded_MacOSX::USBStorageDevicesChanged()