mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 05:00:12 +02:00
* Patch from Sergei Gorelkin, making TStream.Read and .Write virtual
git-svn-id: trunk@9572 -
This commit is contained in:
parent
39d1d07182
commit
b244f6eb71
@ -40,7 +40,6 @@ type
|
||||
constructor Create(AOutputStream: TStream);
|
||||
destructor Destroy; override;
|
||||
|
||||
function Read(var Buffer; Count: Longint): Longint; override;
|
||||
function Write(const Buffer; Count: Longint): Longint; override;
|
||||
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
||||
end;
|
||||
@ -81,7 +80,6 @@ type
|
||||
procedure Reset;
|
||||
|
||||
function Read(var Buffer; Count: Longint): Longint; override;
|
||||
function Write(const Buffer; Count: Longint): Longint; override;
|
||||
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
||||
|
||||
property EOF: Boolean read fEOF;
|
||||
@ -158,11 +156,6 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TBase64EncodingStream.Read(var Buffer; Count: Longint): Longint;
|
||||
begin
|
||||
raise EStreamError.Create('Invalid stream operation');
|
||||
end;
|
||||
|
||||
function TBase64EncodingStream.Write(const Buffer; Count: Longint): Longint;
|
||||
var
|
||||
ReadNow: LongInt;
|
||||
@ -413,11 +406,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TBase64DecodingStream.Write(const Buffer; Count: Longint): Longint;
|
||||
begin
|
||||
raise EStreamError.Create('Invalid stream operation');
|
||||
end;
|
||||
|
||||
function TBase64DecodingStream.Seek(Offset: Longint; Origin: Word): Longint;
|
||||
begin
|
||||
// TODO: implement Seeking in TBase64DecodingStream
|
||||
|
@ -63,7 +63,6 @@ Type
|
||||
TBlowFishEncryptStream = Class(TBlowFishStream)
|
||||
public
|
||||
Destructor Destroy; override;
|
||||
function Read(var Buffer; Count: Longint): Longint; override;
|
||||
function Write(const Buffer; Count: Longint): Longint; override;
|
||||
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
||||
procedure Flush;
|
||||
@ -72,7 +71,6 @@ Type
|
||||
TBlowFishDeCryptStream = Class(TBlowFishStream)
|
||||
public
|
||||
function Read(var Buffer; Count: Longint): Longint; override;
|
||||
function Write(const Buffer; Count: Longint): Longint; override;
|
||||
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
||||
end;
|
||||
|
||||
@ -80,8 +78,6 @@ Implementation
|
||||
|
||||
ResourceString
|
||||
SNoSeekAllowed = 'Seek not allowed on encryption streams';
|
||||
SNoReadAllowed = 'Reading from encryption stream not allowed';
|
||||
SNoWriteAllowed = 'Writing to decryption stream not allowed';
|
||||
|
||||
{ Blowfish lookup tables }
|
||||
|
||||
@ -581,12 +577,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TBlowFishEncryptStream.Read(var Buffer; Count: Longint): Longint;
|
||||
|
||||
begin
|
||||
Raise EBlowFishError.Create(SNoReadAllowed);
|
||||
end;
|
||||
|
||||
function TBlowFishEncryptStream.Write(const Buffer; Count: Longint): Longint;
|
||||
|
||||
Var
|
||||
@ -673,11 +663,6 @@ begin
|
||||
Inc(FPos,Result);
|
||||
end;
|
||||
|
||||
function TBlowFishDeCryptStream.Write(const Buffer; Count: Longint): Longint;
|
||||
begin
|
||||
Raise EBlowFishError.Create(SNoWriteAllowed);
|
||||
end;
|
||||
|
||||
function TBlowFishDeCryptStream.Seek(Offset: Longint; Origin: Word): Longint;
|
||||
|
||||
Var Buffer : Array[0..1023] of byte;
|
||||
|
@ -38,7 +38,7 @@ Type
|
||||
FCapacity: Integer;
|
||||
procedure SetCapacity(const AValue: Integer);
|
||||
Protected
|
||||
procedure BufferError(Msg : String);
|
||||
procedure BufferError(const Msg : String);
|
||||
Procedure FillBuffer; Virtual;
|
||||
Procedure FlushBuffer; Virtual;
|
||||
Public
|
||||
@ -57,7 +57,6 @@ Type
|
||||
Public
|
||||
Function Seek(Offset: Longint; Origin: Word): Longint; override;
|
||||
Function Read(var ABuffer; ACount : LongInt) : Integer; override;
|
||||
Function Write(Const ABuffer; ACount : LongInt) : Integer; override;
|
||||
end;
|
||||
|
||||
{ TWriteBufStream }
|
||||
@ -66,7 +65,6 @@ Type
|
||||
Public
|
||||
Destructor Destroy; override;
|
||||
Function Seek(Offset: Longint; Origin: Word): Longint; override;
|
||||
Function Read(var ABuffer; ACount : LongInt) : Integer; override;
|
||||
Function Write(Const ABuffer; ACount : LongInt) : Integer; override;
|
||||
end;
|
||||
|
||||
@ -75,8 +73,6 @@ implementation
|
||||
Resourcestring
|
||||
SErrCapacityTooSmall = 'Capacity is less than actual buffer size.';
|
||||
SErrCouldNotFLushBuffer = 'Could not flush buffer';
|
||||
SErrWriteOnlyStream = 'Illegal stream operation: Only writing is allowed.';
|
||||
SErrReadOnlyStream = 'Illegal stream operation: Only reading is allowed.';
|
||||
SErrInvalidSeek = 'Invalid buffer seek operation';
|
||||
|
||||
{ TBufStream }
|
||||
@ -92,7 +88,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBufStream.BufferError(Msg: String);
|
||||
procedure TBufStream.BufferError(const Msg: String);
|
||||
begin
|
||||
Raise EStreamError.Create(Msg);
|
||||
end;
|
||||
@ -222,11 +218,6 @@ begin
|
||||
Inc(FTotalPos,Result);
|
||||
end;
|
||||
|
||||
function TReadBufStream.Write(const ABuffer; ACount: LongInt): Integer;
|
||||
begin
|
||||
BufferError(SErrReadOnlyStream);
|
||||
end;
|
||||
|
||||
{ TWriteBufStream }
|
||||
|
||||
destructor TWriteBufStream.Destroy;
|
||||
@ -243,11 +234,6 @@ begin
|
||||
BufferError(SErrInvalidSeek);
|
||||
end;
|
||||
|
||||
function TWriteBufStream.Read(var ABuffer; ACount: LongInt): Integer;
|
||||
begin
|
||||
BufferError(SErrWriteOnlyStream);
|
||||
end;
|
||||
|
||||
function TWriteBufStream.Write(const ABuffer; ACount: LongInt): Integer;
|
||||
|
||||
Var
|
||||
|
@ -85,7 +85,6 @@ Type
|
||||
TIDEAEncryptStream = Class(TIDEAStream)
|
||||
public
|
||||
Destructor Destroy; override;
|
||||
function Read(var Buffer; Count: Longint): Longint; override;
|
||||
function Write(const Buffer; Count: Longint): Longint; override;
|
||||
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
||||
procedure Flush;
|
||||
@ -94,7 +93,6 @@ Type
|
||||
TIDEADeCryptStream = Class(TIDEAStream)
|
||||
public
|
||||
function Read(var Buffer; Count: Longint): Longint; override;
|
||||
function Write(const Buffer; Count: Longint): Longint; override;
|
||||
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
||||
end;
|
||||
|
||||
@ -102,8 +100,6 @@ Implementation
|
||||
|
||||
Const
|
||||
SNoSeekAllowed = 'Seek not allowed on encryption streams';
|
||||
SNoReadAllowed = 'Reading from encryption stream not allowed';
|
||||
SNoWriteAllowed = 'Writing to decryption stream not allowed';
|
||||
|
||||
PROCEDURE mul(VAR a:Word; b: Word);
|
||||
VAR p: LongInt;
|
||||
@ -288,12 +284,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TIDEAEncryptStream.Read(var Buffer; Count: Longint): Longint;
|
||||
|
||||
begin
|
||||
Raise EIDEAError.Create(SNoReadAllowed);
|
||||
end;
|
||||
|
||||
function TIDEAEncryptStream.Write(const Buffer; Count: Longint): Longint;
|
||||
|
||||
Var
|
||||
@ -382,11 +372,6 @@ begin
|
||||
Inc(FPos,Result);
|
||||
end;
|
||||
|
||||
function TIDEADeCryptStream.Write(const Buffer; Count: Longint): Longint;
|
||||
begin
|
||||
Raise EIDEAError.Create(SNoWriteAllowed);
|
||||
end;
|
||||
|
||||
function TIDEADeCryptStream.Seek(Offset: Longint; Origin: Word): Longint;
|
||||
|
||||
Var Buffer : Array[0..1023] of byte;
|
||||
|
@ -23,8 +23,6 @@ Uses sysutils,Classes;
|
||||
|
||||
Type
|
||||
EPipeError = Class(EStreamError);
|
||||
ENoReadPipe = Class(EPipeError);
|
||||
ENoWritePipe = Class (EPipeError);
|
||||
EPipeSeek = Class (EPipeError);
|
||||
EPipeCreation = Class (EPipeError);
|
||||
|
||||
@ -52,8 +50,6 @@ Procedure CreatePipeStreams (Var InPipe : TInputPipeStream;
|
||||
Var OutPipe : TOutputPipeStream);
|
||||
|
||||
Const EPipeMsg = 'Failed to create pipe.';
|
||||
ENoReadMSg = 'Cannot read from OuputPipeStream.';
|
||||
ENoWriteMsg = 'Cannot write to InputPipeStream.';
|
||||
ENoSeekMsg = 'Cannot seek on pipes';
|
||||
|
||||
|
||||
@ -79,7 +75,8 @@ end;
|
||||
Function TInputPipeStream.Write (Const Buffer; Count : Longint) : longint;
|
||||
|
||||
begin
|
||||
Raise ENoWritePipe.Create (ENoWriteMsg);
|
||||
WriteNotImplemented;
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
Function TInputPipeStream.Read (Var Buffer; Count : Longint) : longint;
|
||||
@ -115,7 +112,8 @@ end;
|
||||
Function TOutputPipeStream.Read(Var Buffer; Count : Longint) : longint;
|
||||
|
||||
begin
|
||||
Raise ENoReadPipe.Create (ENoReadMsg);
|
||||
ReadNotImplemented;
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
Function TOutputPipeStream.Seek (Offset : Longint;Origin : Word) : longint;
|
||||
|
@ -14,6 +14,29 @@
|
||||
{* TStream *}
|
||||
{****************************************************************************}
|
||||
|
||||
procedure TStream.ReadNotImplemented;
|
||||
begin
|
||||
raise EStreamError.CreateFmt(SStreamNoReading, [ClassName]) at get_caller_addr(get_frame);
|
||||
end;
|
||||
|
||||
procedure TStream.WriteNotImplemented;
|
||||
begin
|
||||
raise EStreamError.CreateFmt(SStreamNoWriting, [ClassName]) at get_caller_addr(get_frame);
|
||||
end;
|
||||
|
||||
function TStream.Read(var Buffer; Count: Longint): Longint;
|
||||
begin
|
||||
ReadNotImplemented;
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TStream.Write(const Buffer; Count: Longint): Longint;
|
||||
begin
|
||||
WriteNotImplemented;
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
|
||||
function TStream.GetPosition: Int64;
|
||||
|
||||
begin
|
||||
@ -340,7 +363,7 @@
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TStream.WriteAnsiString (S : String);
|
||||
Procedure TStream.WriteAnsiString (const S : String);
|
||||
|
||||
Var L : Longint;
|
||||
|
||||
@ -771,13 +794,6 @@ destructor TResourceStream.Destroy;
|
||||
inherited destroy;
|
||||
end;
|
||||
|
||||
{$warnings off}
|
||||
function TResourceStream.Write(const Buffer; Count: Longint): Longint;
|
||||
begin
|
||||
raise EStreamError.Create(SCantWriteResourceStreamError);
|
||||
end;
|
||||
{$warnings on}
|
||||
|
||||
{****************************************************************************}
|
||||
{* TOwnerStream *}
|
||||
{****************************************************************************}
|
||||
|
@ -248,6 +248,8 @@ ResourceString
|
||||
SSocketRead = 'Read';
|
||||
SSocketWrite = 'Write';
|
||||
SSortedListError = 'Operation not allowed on sorted list';
|
||||
SStreamNoReading = 'Reading from %s is not supported';
|
||||
SStreamNoWriting = 'Writing to %s is not supported';
|
||||
SStreamSetSize = 'Error setting stream size';
|
||||
SStringExpected = 'String expected';
|
||||
SSymbolExpected = '%s expected';
|
||||
|
Loading…
Reference in New Issue
Block a user