summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: af3c404)
raw | patch | inline | side by side (parent: af3c404)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 22 Apr 2016 15:01:40 +0000 (18:01 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 22 Apr 2016 15:06:36 +0000 (18:06 +0300) |
src/shared/xstreams.pas | patch | blob | history |
index e7e70e70ef79769651fb825edf1243e1f243ef3d..270d292e88bc80464d699d34951672e4bfa1b4e4 100644 (file)
--- a/src/shared/xstreams.pas
+++ b/src/shared/xstreams.pas
fSize := aSize;
GetMem(fBuffer, ZBufSize);
fSkipHeader := aSkipHeader;
+ fSrcStPos := fSrcSt.position;
+ FillChar(fZlibSt, sizeof(fZlibSt), 0);
if fSkipHeader then err := inflateInit2(fZlibSt, -MAX_WBITS) else err := inflateInit(fZlibSt);
if err <> Z_OK then raise XStreamError.Create(zerror(err));
- fSrcStPos := fSrcSt.position;
end;
sz: LongInt;
begin
result := 0;
+ if (fSize >= 0) and (fPos >= fSize) then exit;
if count > 0 then
begin
fZlibSt.next_out := @buffer;
//writeln(' reading ', rd, ' bytes...');
rr := readBuf(buf, rd);
//writeln(' got ', rr, ' bytes; fPos=', fPos, '; fSkipToPos=', fSkipToPos);
- if rd <> rr then raise XStreamError.Create('seek error');
+ if rd <= 0 then raise XStreamError.Create('seek error');
end;
//writeln(' pos: fPos=', fPos, '; fSkipToPos=', fSkipToPos);
fSkipToPos := -1;
while true do
begin
rd := readBuf(buf, 4096);
- if rd <> 4096 then break;
+ if rd = 0 then break;
end;
fSize := fPos;
//writeln(' unzstream size is ', fSize);
finally
- fSkipToPos := opos;
+ if fSkipToPos < 0 then fSkipToPos := opos;
end;
end;
var
err: Integer;
begin
+ //writeln('doing RESET');
fSrcSt.position := fSrcStPos;
fPos := 0;
inflateEnd(fZlibSt);
+ FillChar(fZlibSt, sizeof(fZlibSt), 0);
if fSkipHeader then err := inflateInit2(fZlibSt, -MAX_WBITS) else err := inflateInit(fZlibSt);
if err <> Z_OK then raise XStreamError.Create(zerror(err));
end;