mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Support "eject" on OS X.
Change-Id: I103587f2fad2b8b31a1bc53afbd107bf55f62c93
This commit is contained in:
parent
f902bbe07e
commit
1c975eefd3
2 changed files with 40 additions and 1 deletions
|
@ -748,6 +748,45 @@ bool Utils::ejectDevice(QString device)
|
|||
CloseHandle(hdl);
|
||||
return success;
|
||||
|
||||
#endif
|
||||
#if defined(Q_OS_MACX)
|
||||
// FIXME: FSUnmountVolumeSync is deprecated starting with 10.8.
|
||||
// Use DADiskUnmount / DiskArbitration framework eventually.
|
||||
// BSD label does not include folder.
|
||||
QString bsd = Utils::resolveDevicename(device).remove("/dev/");
|
||||
OSStatus result;
|
||||
ItemCount index = 1;
|
||||
bool found = false;
|
||||
|
||||
do {
|
||||
FSVolumeRefNum volrefnum;
|
||||
|
||||
result = FSGetVolumeInfo(kFSInvalidVolumeRefNum, index, &volrefnum,
|
||||
kFSVolInfoFSInfo, NULL, NULL, NULL);
|
||||
if(result == noErr) {
|
||||
GetVolParmsInfoBuffer volparms;
|
||||
HParamBlockRec hpb;
|
||||
hpb.ioParam.ioNamePtr = NULL;
|
||||
hpb.ioParam.ioVRefNum = volrefnum;
|
||||
hpb.ioParam.ioBuffer = (Ptr)&volparms;
|
||||
hpb.ioParam.ioReqCount = sizeof(volparms);
|
||||
|
||||
if(PBHGetVolParmsSync(&hpb) == noErr) {
|
||||
if(volparms.vMServerAdr == 0) {
|
||||
if(bsd == (char*)volparms.vMDeviceID) {
|
||||
pid_t dissenter;
|
||||
result = FSUnmountVolumeSync(volrefnum, 0, &dissenter);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
index++;
|
||||
} while(result == noErr);
|
||||
if(result == noErr && found)
|
||||
return true;
|
||||
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_WIN32)
|
||||
#if !defined(Q_OS_WIN32) && !defined(Q_OS_MACX)
|
||||
/* eject funtionality is only implemented on W32 right now. */
|
||||
ui.buttonEject->setEnabled(false);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue