mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-11 12:58:11 +02:00
* another patch for seeking in compressed streams by Danny Milosavljevic, resolves #12830
git-svn-id: trunk@12705 -
This commit is contained in:
parent
1f75d8734d
commit
d6ba5ab341
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -7694,6 +7694,7 @@ tests/test/packages/hash/tmdtest.pp svneol=native#text/plain
|
||||
tests/test/packages/webtbs/tw10045.pp svneol=native#text/plain
|
||||
tests/test/packages/webtbs/tw11142.pp svneol=native#text/plain
|
||||
tests/test/packages/webtbs/tw11570.pp svneol=native#text/plain
|
||||
tests/test/packages/webtbs/tw12830.pp svneol=native#text/plain
|
||||
tests/test/packages/webtbs/tw1808.pp svneol=native#text/plain
|
||||
tests/test/packages/webtbs/tw3820.pp svneol=native#text/plain
|
||||
tests/test/packages/win-base/tdispvar1.pp svneol=native#text/plain
|
||||
|
@ -70,6 +70,7 @@ type
|
||||
raw_read,compressed_read:longint;
|
||||
skipheader:boolean;
|
||||
procedure reset;
|
||||
function GetPosition() : Int64; override;
|
||||
public
|
||||
constructor create(Asource:Tstream;Askipheader:boolean=false);
|
||||
destructor destroy;override;
|
||||
@ -321,6 +322,11 @@ begin
|
||||
raise Edecompressionerror.create(zerror(err));
|
||||
end;
|
||||
|
||||
function Tdecompressionstream.GetPosition() : Int64;
|
||||
begin
|
||||
GetPosition := raw_read;
|
||||
end;
|
||||
|
||||
function Tdecompressionstream.seek(offset:longint;origin:word):longint;
|
||||
|
||||
var c:longint;
|
||||
@ -330,7 +336,7 @@ begin
|
||||
((origin=sofromcurrent) and (offset+raw_read>=0)) then
|
||||
begin
|
||||
if origin = sofromcurrent then
|
||||
seek := compressed_read - offset
|
||||
seek := raw_read + offset
|
||||
else
|
||||
seek := offset;
|
||||
|
||||
|
22
tests/test/packages/webtbs/tw12830.pp
Normal file
22
tests/test/packages/webtbs/tw12830.pp
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
{$ASSERTIONS ON}
|
||||
|
||||
uses zstream, sysutils, classes;
|
||||
|
||||
var
|
||||
fEncoder : zstream.Tcompressionstream;
|
||||
fDecoder : zstream.Tdecompressionstream;
|
||||
fExpectedString : Shortstring;
|
||||
fCompressedStream : TStream;
|
||||
fBuffer : array[0..9] of Char;
|
||||
begin
|
||||
fCompressedStream := TMemoryStream.Create();
|
||||
fExpectedString := 'test me test me I hope this is compressible test me compressible is test me';
|
||||
fEncoder := zstream.Tcompressionstream.Create(clMax, fCompressedStream);
|
||||
fEncoder.Write(fExpectedString[1], Length(fExpectedString));
|
||||
FreeAndNil(fEncoder);
|
||||
fCompressedStream.Position := 0;
|
||||
fDecoder := zstream.Tdecompressionstream.Create(fCompressedStream);
|
||||
fDecoder.Read(fBuffer, 10);
|
||||
assert(fDecoder.Position = 10);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user