Alexander c585c2f0cb Initial
Исходный код версии 2.0
2022-05-04 07:31:33 +03:00

38 lines
828 B
ObjectPascal

unit uMyUnix;
{$mode objfpc}{$H+}
{$packrecords c}
{$IF NOT DEFINED(LINUX)}
{$DEFINE FPC_USE_LIBC}
{$ENDIF}
interface
uses
Classes, SysUtils, BaseUnix, CTypes, uDrive;
function fpSystemStatus(Command: string): cint;
function EjectDrive(Drive: PDrive): Boolean;
implementation
uses
URIParser, Unix, Process, LazUTF8
{$IF (NOT DEFINED(FPC_USE_LIBC)) or (DEFINED(BSD) AND NOT DEFINED(DARWIN))}
, SysCall
{$ENDIF}
;
function fpSystemStatus(Command: string): cint;
begin
Result := fpSystem(UTF8ToSys(Command));
if wifexited(Result) then
Result := wexitStatus(Result);
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;
end.