decodeascii85.pp 758 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. program decodeascii85;
  2. {$mode objfpc}{$H+}
  3. uses
  4. Classes, SysUtils, ascii85;
  5. var
  6. B : TAscii85DecoderStream;
  7. Fin,Fout : TFileStream;
  8. Buf : Array[1..1024] of Byte;
  9. FN : String;
  10. Count : Integer;
  11. begin
  12. If (ParamCount=0) then
  13. begin
  14. Writeln('usage: decodeascii85 filename');
  15. halt(1);
  16. end;
  17. FN:=ParamStr(1);
  18. FIn:=TFileStream.Create(FN,fmOpenRead);
  19. B:=TAscii85DecoderStream.Create(FIn);
  20. try
  21. FN:=ChangeFileExt(FN,'');
  22. FOut:=TFileStream.Create(FN,fmCreate);
  23. try
  24. Repeat
  25. Count:=B.Read(Buf,SizeOf(Buf));
  26. If Count>0 then
  27. FOut.WriteBuffer(Buf,Count);
  28. Until (Count<SizeOf(Buf));
  29. Finally
  30. Fout.Free;
  31. end;
  32. finally
  33. B.Free;
  34. end;
  35. end.