|
@@ -173,11 +173,11 @@ Var
|
|
|
Function DetectXTerm : String;
|
|
|
{$endif unix}
|
|
|
|
|
|
-function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string;var exitstatus:integer):integer;
|
|
|
-function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string):boolean;
|
|
|
+function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string;var exitstatus:integer):integer;
|
|
|
+function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string):boolean;
|
|
|
function RunCommandInDir(const curdir,cmdline:string;var outputstring:string):boolean; deprecated;
|
|
|
|
|
|
-function RunCommand(const exename:string;const commands:array of string;var outputstring:string):boolean;
|
|
|
+function RunCommand(const exename:string;const commands:array of string;var outputstring:string):boolean;
|
|
|
function RunCommand(const cmdline:string;var outputstring:string):boolean; deprecated;
|
|
|
|
|
|
implementation
|
|
@@ -321,7 +321,7 @@ end;
|
|
|
procedure TProcess.Loaded;
|
|
|
begin
|
|
|
inherited Loaded;
|
|
|
- If (csDesigning in ComponentState) and (CommandLine<>'') then
|
|
|
+ If (csDesigning in ComponentState) and (FCommandLine<>'') then
|
|
|
ConvertCommandLine;
|
|
|
end;
|
|
|
|
|
@@ -460,7 +460,7 @@ end;
|
|
|
procedure TProcess.ConvertCommandLine;
|
|
|
begin
|
|
|
FParameters.Clear;
|
|
|
- CommandToList(CommandLine,FParameters);
|
|
|
+ CommandToList(FCommandLine,FParameters);
|
|
|
If FParameters.Count>0 then
|
|
|
begin
|
|
|
Executable:=FParameters[0];
|
|
@@ -468,7 +468,7 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-Const
|
|
|
+Const
|
|
|
READ_BYTES = 65536; // not too small to avoid fragmentation when reading large files.
|
|
|
|
|
|
// helperfunction that does the bulk of the work.
|
|
@@ -483,25 +483,25 @@ begin
|
|
|
bytesread:=0;
|
|
|
p.Execute;
|
|
|
while p.Running do
|
|
|
- begin
|
|
|
+ begin
|
|
|
Setlength(outputstring,BytesRead + READ_BYTES);
|
|
|
NumBytes := p.Output.Read(outputstring[1+bytesread], READ_BYTES);
|
|
|
- if NumBytes > 0 then
|
|
|
+ if NumBytes > 0 then
|
|
|
Inc(BytesRead, NumBytes)
|
|
|
- else
|
|
|
- Sleep(100);
|
|
|
+ else
|
|
|
+ Sleep(100);
|
|
|
end;
|
|
|
repeat
|
|
|
Setlength(outputstring,BytesRead + READ_BYTES);
|
|
|
NumBytes := p.Output.Read(outputstring[1+bytesread], READ_BYTES);
|
|
|
- if NumBytes > 0 then
|
|
|
+ if NumBytes > 0 then
|
|
|
Inc(BytesRead, NumBytes);
|
|
|
until NumBytes <= 0;
|
|
|
setlength(outputstring,BytesRead);
|
|
|
exitstatus:=p.exitstatus;
|
|
|
result:=0; // we came to here, document that.
|
|
|
except
|
|
|
- on e : Exception do
|
|
|
+ on e : Exception do
|
|
|
begin
|
|
|
result:=1;
|
|
|
setlength(outputstring,BytesRead);
|
|
@@ -512,16 +512,16 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string;var exitstatus:integer):integer;
|
|
|
+function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string;var exitstatus:integer):integer;
|
|
|
Var
|
|
|
p : TProcess;
|
|
|
- i : integer;
|
|
|
+ i : integer;
|
|
|
begin
|
|
|
p:=TProcess.create(nil);
|
|
|
- p.Executable:=exename;
|
|
|
+ p.Executable:=exename;
|
|
|
if curdir<>'' then
|
|
|
p.CurrentDirectory:=curdir;
|
|
|
- if high(commands)>=0 then
|
|
|
+ if high(commands)>=0 then
|
|
|
for i:=low(commands) to high(commands) do
|
|
|
p.Parameters.add(commands[i]);
|
|
|
result:=internalruncommand(p,outputstring,exitstatus);
|
|
@@ -530,27 +530,27 @@ end;
|
|
|
function RunCommandInDir(const curdir,cmdline:string;var outputstring:string):boolean; deprecated;
|
|
|
Var
|
|
|
p : TProcess;
|
|
|
- exitstatus : integer;
|
|
|
+ exitstatus : integer;
|
|
|
begin
|
|
|
p:=TProcess.create(nil);
|
|
|
- p.commandline:=cmdline;
|
|
|
+ p.setcommandline(cmdline);
|
|
|
if curdir<>'' then
|
|
|
p.CurrentDirectory:=curdir;
|
|
|
result:=internalruncommand(p,outputstring,exitstatus)=0;
|
|
|
if exitstatus<>0 then result:=false;
|
|
|
end;
|
|
|
|
|
|
-function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string):boolean;
|
|
|
+function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string):boolean;
|
|
|
Var
|
|
|
p : TProcess;
|
|
|
i,
|
|
|
- exitstatus : integer;
|
|
|
+ exitstatus : integer;
|
|
|
begin
|
|
|
p:=TProcess.create(nil);
|
|
|
- p.Executable:=exename;
|
|
|
+ p.Executable:=exename;
|
|
|
if curdir<>'' then
|
|
|
p.CurrentDirectory:=curdir;
|
|
|
- if high(commands)>=0 then
|
|
|
+ if high(commands)>=0 then
|
|
|
for i:=low(commands) to high(commands) do
|
|
|
p.Parameters.add(commands[i]);
|
|
|
result:=internalruncommand(p,outputstring,exitstatus)=0;
|
|
@@ -560,23 +560,23 @@ end;
|
|
|
function RunCommand(const cmdline:string;var outputstring:string):boolean; deprecated;
|
|
|
Var
|
|
|
p : TProcess;
|
|
|
- exitstatus : integer;
|
|
|
+ exitstatus : integer;
|
|
|
begin
|
|
|
p:=TProcess.create(nil);
|
|
|
- p.commandline:=cmdline;
|
|
|
+ p.setcommandline(cmdline);
|
|
|
result:=internalruncommand(p,outputstring,exitstatus)=0;
|
|
|
if exitstatus<>0 then result:=false;
|
|
|
end;
|
|
|
|
|
|
-function RunCommand(const exename:string;const commands:array of string;var outputstring:string):boolean;
|
|
|
+function RunCommand(const exename:string;const commands:array of string;var outputstring:string):boolean;
|
|
|
Var
|
|
|
p : TProcess;
|
|
|
i,
|
|
|
- exitstatus : integer;
|
|
|
+ exitstatus : integer;
|
|
|
begin
|
|
|
p:=TProcess.create(nil);
|
|
|
- p.Executable:=exename;
|
|
|
- if high(commands)>=0 then
|
|
|
+ p.Executable:=exename;
|
|
|
+ if high(commands)>=0 then
|
|
|
for i:=low(commands) to high(commands) do
|
|
|
p.Parameters.add(commands[i]);
|
|
|
result:=internalruncommand(p,outputstring,exitstatus)=0;
|