[fpc-pascal] GZip - Stream decompress only in memory
silvioprog
silvioprog at gmail.com
Mon Sep 5 00:37:17 CEST 2016
On Sep 4, 2016 5:29 PM, "Marcos Douglas" <md at delfire.net> wrote:
>
> Ok, it works now.
Great!
> For the records, I've used the lib http://www.gocher.me/GZIP (Silvio's
> tip) and the function Base64Decode from WST framework
> http://svn.code.sf.net/p/lazarus-ccr/svn/wst/trunk/
>
> For some reason the function DecodeBase64 from Synapse doesn't work.
> It receives an AnsiString. Instead, the Base64Decode function receives
> a TByteDynArray.
>
> The TDataStream class doesn't matter...
>
> So, the code below is ugly, but shows how it works now (before the
refactoring).
>
> Thank you all for the help.
>
> === begin ===
>
> procedure TMainForm.Button2Click(Sender: TObject);
> var
> Buf,Buf2: TMemoryStream;
> B: TByteDynArray;
> begin
> Buf := TMemoryStream.Create;
> Buf2 := TMemoryStream.Create;
> try
> Buf.LoadFromFile('result.txt');
> B := Base64Decode(TDataStream.New(Buf).AsString,
> [xoDecodeIgnoreIllegalChar]);
> Buf.SaveToFile('bytes.txt');
> Buf.Clear;
> Buf.WriteBuffer(Pointer(B)^, Length(B));
I'm on the phone, but looking this part it seems that base64 unconversion
can be done directly in memory too. I can try it after...
> if ZUncompressStream(Buf, Buf2) then
> Buf2.SaveToFile('content.txt');
> finally
> Buf.Free;
> Buf2.Free;
> end;
> end;
>
> === end ===
>
> Best regards,
> Marcos Douglas
--
Silvio Clecio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160904/6cef1835/attachment.html>
More information about the fpc-pascal
mailing list