summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/fcl-base/examples/decodeascii85.pp
blob: a32bce3ada6bb430e8766ce272e8bac0a646fb0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
program decodeascii85;

{$mode objfpc}{$H+}

uses
  Classes, SysUtils, ascii85;

var
  B : TAscii85DecoderStream;
  Fin,Fout : TFileStream;
  Buf : Array[1..1024] of Byte;
  FN : String;
  Count : Integer;

begin
  If (ParamCount=0) then
    begin
    Writeln('usage: decodeascii85 filename');
    halt(1);
    end;
  FN:=ParamStr(1);
  FIn:=TFileStream.Create(FN,fmOpenRead);
  B:=TAscii85DecoderStream.Create(FIn);
  try
    FN:=ChangeFileExt(FN,'');
    FOut:=TFileStream.Create(FN,fmCreate);
    try
      Repeat
        Count:=B.Read(Buf,SizeOf(Buf));
        If Count>0 then
          FOut.WriteBuffer(Buf,Count);
      Until (Count<SizeOf(Buf));
    Finally
      Fout.Free;
    end;
  finally
    B.Free;
  end;
end.