Merge pull request #8 from btbytes/master

Application now compiles on Mac OSX (Yosemite).
This commit is contained in:
Basile Burg 2015-05-28 05:31:28 +02:00
commit 9b9fefd0d0
1 changed files with 40 additions and 0 deletions

View File

@ -659,6 +659,18 @@ begin
Free;
end;
{$ENDIF}
{$IFDEF DARWIN}
with TProcess.Create(nil) do
try
Executable := 'open';
Parameters.Add(aFilename);
Execute;
finally
result := true;
Free;
end;
{$ENDIF}
end;
function exeInSysPath(anExeName: string): boolean;
@ -911,6 +923,34 @@ begin
end;
{$ENDIF}
{$IFDEF DARWIN}
function internalAppIsRunning(const ExeName: string): integer;
var
proc: TProcess;
lst: TStringList;
begin
Result := 0;
proc := tprocess.Create(nil);
proc.Executable := 'pgrep';
proc.Parameters.Add(ExeName);
proc.Options := [poUsePipes, poWaitonexit];
try
proc.Execute;
lst := TStringList.Create;
try
lst.LoadFromStream(proc.Output);
Result := StrToIntDef(Trim(lst.Text), 0);
finally
lst.Free;
end;
finally
proc.Free;
end;
end;
{$ENDIF}
function AppIsRunning(const ExeName: string):Boolean;
begin
Result:= internalAppIsRunning(ExeName) > 0;