* Patch from Vincent Snijders to implement NumberOfBytesAvailable for pipes

git-svn-id: trunk@6275 -
This commit is contained in:
michael 2007-01-31 16:28:12 +00:00
parent 1a32e4fdf5
commit 4155eb6e04
11 changed files with 89 additions and 4 deletions

View File

@ -20,3 +20,11 @@ Function CreatePipeHandles (Var Inhandle,OutHandle : Longint) : Boolean;
begin
Result := False;
end;
Function TInputPipeStream.GetNumBytesAvailable: DWord;
begin
Result := 0;
end;

View File

@ -13,10 +13,18 @@
**********************************************************************}
// No pipes under dos, sorry...
// No pipes under beos, sorry...
Function CreatePipeHandles (Var Inhandle,OutHandle : Longint) : Boolean;
begin
Result := False;
end;
Function TInputPipeStream.GetNumBytesAvailable: DWord;
begin
Result := 0;
end;

View File

@ -20,3 +20,11 @@ Function CreatePipeHandles (Var Inhandle,OutHandle : THandle) : Boolean;
begin
Result := False;
end;
Function TInputPipeStream.GetNumBytesAvailable: DWord;
begin
Result := 0;
end;

View File

@ -28,13 +28,17 @@ Type
EPipeSeek = Class (EPipeError);
EPipeCreation = Class (EPipeError);
{ TInputPipeStream }
TInputPipeStream = Class(THandleStream)
Private
FPos : Int64;
function GetNumBytesAvailable: DWord;
public
Function Write (Const Buffer; Count : Longint) :Longint; Override;
Function Seek (Offset : Longint;Origin : Word) : longint;override;
Function Read (Var Buffer; Count : Longint) : longint; Override;
property NumBytesAvailable: DWord read GetNumBytesAvailable;
end;
TOutputPipeStream = Class(THandleStream)

View File

@ -20,3 +20,11 @@ Function CreatePipeHandles (Var Inhandle,OutHandle : Longint) : Boolean;
begin
Result := False;
end;
Function TInputPipeStream.GetNumBytesAvailable: DWord;
begin
Result := 0;
end;

View File

@ -13,6 +13,7 @@
**********************************************************************}
// Unsupported for the moment...
Function CreatePipeHandles (Var Inhandle,OutHandle : THandle) : Boolean;
@ -20,3 +21,10 @@ begin
Result := false; {dont know how to do that with netware clib}
end;
Function TInputPipeStream.GetNumBytesAvailable: DWord;
begin
Result := 0;
end;

View File

@ -13,6 +13,7 @@
**********************************************************************}
// Unsupported for the moment...
Function CreatePipeHandles (Var Inhandle,OutHandle : THandle) : Boolean;
@ -20,3 +21,10 @@ begin
Result := false; {todo}
end;
Function TInputPipeStream.GetNumBytesAvailable: DWord;
begin
Result := 0;
end;

View File

@ -24,3 +24,11 @@ Function CreatePipeHandles (Var Inhandle,OutHandle : Longint) : Boolean;
begin
CreatePipeHandles := DosCreatePipe (InHandle, OutHandle, PipeBufSize) = 0;
end;
Function TInputPipeStream.GetNumBytesAvailable: DWord;
begin
// TODO: find out if this is possible in OS/2
Result := 0;
end;

View File

@ -14,8 +14,7 @@
**********************************************************************}
Uses
Unix
;
BaseUnix, Unix, TermIO;
Function CreatePipeHandles (Var Inhandle,OutHandle : Longint) : Boolean;
@ -23,3 +22,11 @@ begin
Result := (AssignPipe (Inhandle,OutHandle)<>-1);
end;
Function TInputPipeStream.GetNumBytesAvailable: DWord;
begin
if fpioctl(Handle, FIONREAD, @Result)<0 then
Result := 0;
end;

View File

@ -33,3 +33,11 @@ Function CreatePipeHandles (Var Inhandle,OutHandle : THandle) : Boolean;
begin
Result := CreatePipe (@Inhandle,@OutHandle,@piInheritablePipe,PipeBufSize);
end;
Function TInputPipeStream.GetNumBytesAvailable: DWord;
begin
if not PeekNamedPipe(Handle, nil, 0, nil, @Result, nil) then
Result := 0;
end;

View File

@ -13,8 +13,18 @@
**********************************************************************}
// Unsupported for the moment...
Function CreatePipeHandles (Var Inhandle,OutHandle : THandle) : Boolean;
// No pipes under dos, sorry...
begin
Result := False;
end;
Function TInputPipeStream.GetNumBytesAvailable: DWord;
begin
// Windows CE doesn´t have the API function PeekNamedPipe
Result := 0;
end;