mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-03 01:50:26 +02:00
* Simulate position
This commit is contained in:
parent
dbd87a3cfc
commit
5288194d3c
@ -88,6 +88,7 @@ Type
|
|||||||
FOutSize : Cardinal;
|
FOutSize : Cardinal;
|
||||||
FOutRead : Cardinal;
|
FOutRead : Cardinal;
|
||||||
FFirstRead : Boolean;
|
FFirstRead : Boolean;
|
||||||
|
FPosition : Int64;
|
||||||
procedure MoveFromBuffer(Dest: PByte; aCount: Integer);
|
procedure MoveFromBuffer(Dest: PByte; aCount: Integer);
|
||||||
Protected
|
Protected
|
||||||
function ReadByte(out aByte: Byte): Boolean;
|
function ReadByte(out aByte: Byte): Boolean;
|
||||||
@ -98,8 +99,11 @@ Type
|
|||||||
procedure WriteStringFromCode(aCode: integer; AddFirstChar: boolean = false);
|
procedure WriteStringFromCode(aCode: integer; AddFirstChar: boolean = false);
|
||||||
Procedure FillInBuffer;
|
Procedure FillInBuffer;
|
||||||
Procedure FillOutBuffer;
|
Procedure FillOutBuffer;
|
||||||
|
function GetPosition: Int64; override;
|
||||||
|
procedure SetPosition(const Pos: Int64); override;
|
||||||
Public
|
Public
|
||||||
Constructor Create(aSource : TStream; aOptions : TLZWStreamOptions; InitialBufsize : Word = LZWDefaultBufSize); overload;
|
Constructor Create(aSource : TStream; aOptions : TLZWStreamOptions; InitialBufsize : Word = LZWDefaultBufSize); overload;
|
||||||
|
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;
|
||||||
function Read(var Buffer; Count: Longint): Longint; override;
|
function Read(var Buffer; Count: Longint): Longint; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -278,7 +282,7 @@ end;
|
|||||||
procedure TLZWDecompressionStream.WriteStringFromCode(aCode: integer; AddFirstChar: boolean = false);
|
procedure TLZWDecompressionStream.WriteStringFromCode(aCode: integer; AddFirstChar: boolean = false);
|
||||||
var
|
var
|
||||||
s: TLZWString;
|
s: TLZWString;
|
||||||
i : Integer;
|
// i : Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// WriteLn('WriteStringFromCode Code=',aCode,' AddFirstChar=',AddFirstChar);
|
// WriteLn('WriteStringFromCode Code=',aCode,' AddFirstChar=',AddFirstChar);
|
||||||
@ -378,6 +382,18 @@ begin
|
|||||||
until FOutSize>=FillCapacity;
|
until FOutSize>=FillCapacity;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLZWDecompressionStream.GetPosition: Int64;
|
||||||
|
begin
|
||||||
|
Result:=FPosition;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLZWDecompressionStream.SetPosition(const Pos: Int64);
|
||||||
|
begin
|
||||||
|
if Pos=FPosition then
|
||||||
|
exit;
|
||||||
|
inherited SetPosition(Pos);
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TLZWDecompressionStream.Create(aSource: TStream;
|
constructor TLZWDecompressionStream.Create(aSource: TStream;
|
||||||
aOptions: TLZWStreamOptions; InitialBufsize: Word);
|
aOptions: TLZWStreamOptions; InitialBufsize: Word);
|
||||||
begin
|
begin
|
||||||
@ -386,6 +402,16 @@ begin
|
|||||||
FOutSize:=0;
|
FOutSize:=0;
|
||||||
FOutRead:=0;
|
FOutRead:=0;
|
||||||
FFirstRead:=True;
|
FFirstRead:=True;
|
||||||
|
FPosition:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TLZWDecompressionStream.Seek(const Offset: Int64; Origin: TSeekOrigin
|
||||||
|
): Int64;
|
||||||
|
begin
|
||||||
|
if (Offset=0) and (Origin=soCurrent) then
|
||||||
|
Result:=FPosition
|
||||||
|
else
|
||||||
|
Result:=inherited Seek(Offset, Origin);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLZWDecompressionStream.MoveFromBuffer(Dest : PByte; aCount : Integer);
|
procedure TLZWDecompressionStream.MoveFromBuffer(Dest : PByte; aCount : Integer);
|
||||||
@ -395,7 +421,7 @@ begin
|
|||||||
Inc(FOutRead,aCount);
|
Inc(FOutRead,aCount);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TLZWDecompressionStream.FillInBuffer;
|
procedure TLZWDecompressionStream.FillInBuffer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FInSize:=Source.Read(FInBuffer,SizeOf(FInBuffer));
|
FInSize:=Source.Read(FInBuffer,SizeOf(FInBuffer));
|
||||||
@ -439,6 +465,7 @@ begin
|
|||||||
if Count>0 then // we need more data
|
if Count>0 then // we need more data
|
||||||
FillOutBuffer;
|
FillOutBuffer;
|
||||||
end;
|
end;
|
||||||
|
Inc(FPosition,Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user