LCL: TAsyncProcess.NumBytesAvailable uses TAsyncProcess.Output.NumBytesAvailable and let the FCL handle the platform dependant details

git-svn-id: trunk@16469 -
This commit is contained in:
vincents 2008-09-07 12:25:27 +00:00
parent 70bed48055
commit 13edb8ff11

View File

@ -25,12 +25,6 @@ unit AsyncProcess;
{$mode objfpc}{$H+}
{$IF defined(VER2_0_2) and defined(win32)}
// FPC <= 2.0.2 compatibility code
// WINDOWS define was added after FPC 2.0.2
{$define WINDOWS}
{$endif}
interface
uses
@ -96,43 +90,14 @@ procedure Register;
implementation
{$ifdef WINDOWS}
uses Windows;
function TAsyncProcess.GetNumBytesAvailable: dword;
begin
{$ifdef wince}
// Windows CE doesn´t have the API function PeekNamedPipe
Result := 0;
{$else}
if not (poUsePipes in Options) then
Result := 0
else
if not PeekNamedPipe(Output.Handle, nil, 0, nil, @Result, nil) then
Result := 0;
{$endif}
Result := Output.NumBytesAvailable;
end;
{$else below for not Windows}
uses BaseUnix, TermIO;
function TAsyncProcess.GetNumBytesAvailable: dword;
begin
if not (poUsePipes in Options) then
Result := 0
else begin
// FIONREAD -> bytes available for reading without blocking
// FIONSPACE -> bytes available for writing without blocking
// does not work on all platforms (not defined on linux e.g.)
if fpioctl(Output.Handle, FIONREAD, @Result)<0 then
Result := 0;
end;
end;
{$endif}
destructor TAsyncProcess.Destroy;
begin
UnhookProcessHandle;