mirror of https://gitlab.com/basile.b/dexed.git
mini explorer, open w/ shell, prevent zombie proc
This commit is contained in:
parent
0aefd3341c
commit
afe9f0088b
|
@ -208,7 +208,7 @@ type
|
||||||
(**
|
(**
|
||||||
* Lets the shell open a file.
|
* Lets the shell open a file.
|
||||||
*)
|
*)
|
||||||
function shellOpen(const fname: string): boolean;
|
function shellOpen(const fname: string; wait: boolean = true): boolean;
|
||||||
|
|
||||||
(**
|
(**
|
||||||
* Returns true if anExeName can be spawn without its full path.
|
* Returns true if anExeName can be spawn without its full path.
|
||||||
|
@ -895,33 +895,29 @@ begin
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function shellOpen(const fname: string): boolean;
|
function shellOpen(const fname: string; wait: boolean = true): boolean;
|
||||||
begin
|
begin
|
||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
result := ShellExecute(0, 'OPEN', PChar(fname), nil, nil, SW_SHOW) > 32;
|
result := ShellExecute(0, 'OPEN', PChar(fname), nil, nil, SW_SHOW) > 32;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF LINUX}
|
|
||||||
with TProcess.Create(nil) do
|
with TProcess.Create(nil) do
|
||||||
try
|
try
|
||||||
|
{$IFDEF LINUX}
|
||||||
Executable := 'xdg-open';
|
Executable := 'xdg-open';
|
||||||
|
{$ELSE}
|
||||||
|
{$IFDEF DARWIN}
|
||||||
|
Executable := 'open';
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
Parameters.Add(fname);
|
Parameters.Add(fname);
|
||||||
Execute;
|
Execute;
|
||||||
|
if wait then
|
||||||
|
while Running do
|
||||||
|
sleep(1);
|
||||||
finally
|
finally
|
||||||
result := true;
|
result := true;
|
||||||
Free;
|
Free;
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
|
||||||
{$IFDEF DARWIN}
|
|
||||||
with TProcess.Create(nil) do
|
|
||||||
try
|
|
||||||
Executable := 'open';
|
|
||||||
Parameters.Add(aFilename);
|
|
||||||
Execute;
|
|
||||||
finally
|
|
||||||
result := true;
|
|
||||||
Free;
|
|
||||||
end;
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function exeInSysPath(fname: string): boolean;
|
function exeInSysPath(fname: string): boolean;
|
||||||
|
|
Loading…
Reference in New Issue