diff --git a/src/ce_common.pas b/src/ce_common.pas index 35ed9f47..e362ddc7 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; @@ -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;