From 42aa1e67ebba3eb5b43d07fae7b4134865ad669c Mon Sep 17 00:00:00 2001 From: Pradeep Gowda Date: Wed, 27 May 2015 22:55:57 -0400 Subject: [PATCH] Add `Open` function. Trim will do the trick of obtaining the pid. No need for RemoveLeadingChars. --- src/ce_common.pas | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ce_common.pas b/src/ce_common.pas index 6d901702..b8ef4c47 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -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; @@ -916,11 +928,8 @@ function internalAppIsRunning(const ExeName: string): integer; var proc: TProcess; lst: TStringList; - stripChars: TSysCharSet; - lstText: AnsiString; begin Result := 0; - stripChars := ['"']; proc := tprocess.Create(nil); proc.Executable := 'pgrep'; proc.Parameters.Add(ExeName); @@ -930,9 +939,7 @@ begin lst := TStringList.Create; try lst.LoadFromStream(proc.Output); - lstText := lst.Text; - RemoveLeadingChars(lstText, stripChars); - Result := StrToInt(lstText); + Result := StrToInt(Trim(lst.Text)); finally lst.Free; end;