UPD: Use diskutil to mount/unmount/eject operations under Mac OS X

This commit is contained in:
Alexander Koblov 2013-11-02 07:07:33 +00:00
commit 3dd67515b9

View file

@ -459,7 +459,7 @@ begin
if Drive^.Path <> EmptyStr then
{$ENDIF}
Result := fpSystemStatus('mount ' + Drive^.DeviceId) = 0;
{$IFDEF LINUX}
{$IF DEFINED(LINUX)}
if not Result and uUDisks.Initialize then
begin
Result := uUDisks.Mount(DeviceFileToUDisksObjectPath(Drive^.DeviceId), EmptyStr, nil, MountPath);
@ -469,6 +469,9 @@ begin
end;
if not Result and HavePMount and Drive^.IsMediaRemovable then
Result := fpSystemStatus('pmount ' + Drive^.DeviceId) = 0;
{$ELSE IF DEFINED(DARWIN)}
if not Result then
Result := fpSystemStatus('diskutil mount ' + Drive^.DeviceId) = 0;
{$ENDIF}
end
else
@ -479,7 +482,7 @@ function UnmountDrive(Drive: PDrive): Boolean;
begin
if Drive^.IsMounted then
begin
{$IFDEF LINUX}
{$IF DEFINED(LINUX)}
Result := False;
if uUDisks.Initialize then
begin
@ -489,6 +492,9 @@ begin
if not Result and HavePMount and Drive^.IsMediaRemovable then
Result := fpSystemStatus('pumount ' + Drive^.DeviceId) = 0;
if not Result then
{$ELSE IF DEFINED(DARWIN)}
Result := fpSystemStatus('diskutil unmount ' + Drive^.DeviceId) = 0;
if not Result then
{$ENDIF}
Result := fpSystemStatus('umount ' + Drive^.Path) = 0;
end
@ -498,6 +504,10 @@ end;
function EjectDrive(Drive: PDrive): Boolean;
begin
{$IF DEFINED(DARWIN)}
Result := fpSystemStatus('diskutil eject ' + Drive^.DeviceId) = 0;
if not Result then
{$ENDIF}
Result := fpSystemStatus('eject ' + Drive^.DeviceId) = 0;
end;