Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error ' Invalid ZStream operation ' Delphi 11.0

Tags:

delphi

I recently migrate to Delphi 11.0 this line 'Zip.CopyFrom(Source, 0); generate 'error 'Invalid ZStream operation'

uses system.ZLib;
...

    const
      ZLIB_GZIP_WINDOWBITS    = 31;
      ZLIB_DEFLATE_WINDOWBITS = 15;
    
    type
      TZLibCompressionLevel = TZCompressionLevel;

procedure ZLibCompressStream(Source, Dest: TStream; const Level: TZLibCompressionLevel;
        const GZipFormat: Boolean);
    var
      WindowBits: Integer;
      Zip: TZCompressionStream;
    begin
      if GZipFormat then
        WindowBits := ZLIB_GZIP_WINDOWBITS
      else
        WindowBits := ZLIB_DEFLATE_WINDOWBITS;
    
      Zip := TZCompressionStream.Create(Dest, Level, WindowBits);
      try
        Zip.CopyFrom(Source, 0);
      finally
        FreeAndNil(Zip);
      end;
    end;
    
    procedure TForm85.Button1Click(Sender: TObject);
    var s1,s2:TMemoryStream;
    begin
     s1:=TMemoryStream.Create;
     s1.LoadFromFile('h:\1.txt') ;
     s2:=TMemoryStream.Create;
     ZLibCompressStream(s1,s2,zcDefault,true);
    
    end;

on Delphi 10 and before no error occurs

like image 434
A.K.D. Avatar asked Mar 25 '26 05:03

A.K.D.


1 Answers

It appears to be fixed in 11.1

like image 187
Jason Chapman Avatar answered Mar 28 '26 02:03

Jason Chapman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!