mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-05 19:10:15 +02:00
* alternate readinput with streams.
git-svn-id: trunk@39568 -
This commit is contained in:
parent
20917b4ec2
commit
00aeae7651
@ -129,6 +129,7 @@ Type
|
||||
Function WaitOnExit : Boolean;
|
||||
Function WaitOnExit(Timeout : DWord) : Boolean;
|
||||
function ReadInputStream(p:TInputPipeStream;var BytesRead:integer;var DataLength:integer;var Data:string;MaxLoops:integer=10):boolean;
|
||||
function ReadInputStream(p:TInputPipeStream;data:TStream;MaxLoops:integer=10):boolean;
|
||||
function RunCommandLoop(out outputstring:string;out stderrstring:string; out anexitstatus:integer):integer;
|
||||
|
||||
Property WindowRect : Trect Read GetWindowRect Write SetWindowRect;
|
||||
@ -509,6 +510,27 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TProcess.ReadInputStream(p:TInputPipeStream;data:TStream;MaxLoops:integer=10):boolean;
|
||||
const
|
||||
BufSize = 4096;
|
||||
var
|
||||
Buffer: array[0..BufSize - 1] of byte;
|
||||
ReadBytes: integer;
|
||||
Available : integer;
|
||||
begin
|
||||
Available:=P.NumBytesAvailable;
|
||||
result:=Available>0;
|
||||
if not result then
|
||||
Exit;
|
||||
while (available > 0) and (MaxLoops>0) do
|
||||
begin
|
||||
ReadBytes := Output.Read({%H-}Buffer, min(BufSize,Available));
|
||||
data.Write(Buffer, ReadBytes);
|
||||
Available:=P.NumBytesAvailable;
|
||||
dec(MaxLoops);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProcess.IntOnIdleSleep(Sender : TObject;status:TRunCommandEventCode;const message:string);
|
||||
begin
|
||||
if status=RunCommandIdle then
|
||||
|
Loading…
Reference in New Issue
Block a user