Browse Source

* Patch from Vincent Snijders to implement NumberOfBytesAvailable for pipes

git-svn-id: trunk@6275 -
michael 18 years ago
parent
commit
4155eb6e04

+ 8 - 0
fcl/amiga/pipes.inc

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

+ 9 - 1
fcl/beos/pipes.inc

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

+ 8 - 0
fcl/go32v2/pipes.inc

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

+ 4 - 0
fcl/inc/pipes.pp

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

+ 8 - 0
fcl/morphos/pipes.inc

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

+ 8 - 0
fcl/netware/pipes.inc

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

+ 8 - 0
fcl/netwlibc/pipes.inc

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

+ 8 - 0
fcl/os2/pipes.inc

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

+ 9 - 2
fcl/unix/pipes.inc

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

+ 8 - 0
fcl/win/pipes.inc

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

+ 11 - 1
fcl/wince/pipes.inc

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