I am still unable to get paszlib to work. I have since gone to some pretty big lengths toward my goal, but I am afraid I am stuck. I think the ideal way would be to be able to read the file into a TMemstream, decompress it into another Tmemstream and then write that out, but I must admit I have no idea how to go about achieving that.
So considering that, for the moment I decided that I may have made a mistake in my code conversions, so I fell back on minigz's own code virtually unaltered, but wrapped inside a component. All I get is that when I call the extract method - the program throws: TApplication.HandleException Access violation Stack trace: $40489AE0 GZ_EXTRACT_finalize_implicit, line 54 of gtkglobals.pp What does an error in finalize MEAN ? I did an strace on the program, and it certainly reads and writes a LOT of data once you trigger the method, so SOMETHING is happening before the crash. I attach my full source code this time, if somebody would like to see the trace I will mail that offlist as it is likely to be huge. I urgently need to get this working to do transparent decompression for OpenBook on windows (calling gunzip only works where gunzip works well). Ciao A.J. -- A.J. Venter Chief Software Architext OpenLab International www.getopenlab.com www.silentcoder.co.za +27 82 726 5103
{ Copyright (C) 2006 A.J. Venter This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. } unit gz_extract; {Note - you must add turbopoweripro to your project requirements for this to work} {$mode objfpc}{$H+} interface uses Classes, SysUtils,Process,zutil,gzIo, Forms, Controls, Graphics, Dialogs; Type TGZ_Extractor = class(TComponent) private FInputFile : String; FOutPutFile : String; public destructor destroy; override; Procedure Extract; published property InputFile : String write FInputFile; property OutPutFile : String write FOutPutFile; constructor create(AOwner: TComponent); override; end; procedure register; Implementation {TGZ_Extractor} const BUFLEN = 16384 ; GZ_SUFFIX = '.gz' ; {$DEFINE MAXSEF_64K} var buf : packed array [0..BUFLEN-1] of byte; { Global uses BSS instead of stack } prog : string; procedure error (msg:string); begin showMessage(msg); end; procedure Register; begin RegisterComponents('OLPack',[TGZ_Extractor]); end; procedure gz_uncompress (infile:gzFile; var outfile:file); var len : int; written : uInt; ioerr : integer; err : int; begin while true do begin len := gzread (infile, @buf, BUFLEN); if (len < 0) then error (gzerror (infile, err)); if (len = 0) then break; {$I-} blockwrite (outfile, buf, len, written); {$I+} if (written <> len) then error ('write error'); end; {WHILE} {$I-} close (outfile); {$I+} ioerr := IOResult; if (ioerr <> 0) then begin writeln ('close error: ',ioerr); halt(1); end; if (gzclose (infile) <> 0{Z_OK}) then error ('gzclose error'); end; procedure file_uncompress (filename,outname:String); var inname : string; infile : gzFile; outfile : file; ioerr : integer; len : integer; begin len := Length(filename); inname := filename; infile := gzopen (inname, 'r'); if (infile = NIL) then begin writeln (prog,': can''t gzopen ',inname); halt(1); end; Assign (outfile, outname); {$I-} Rewrite (outfile,1); {$I+} ioerr := IOResult; if (ioerr <> 0) then begin writeln ('open error: ',ioerr); halt(1); end; gz_uncompress (infile, outfile); end; Procedure TGZ_Extractor.Extract; Begin File_UnCompress(FInputFile,FOutPutFile); end; destructor TGZ_Extractor.destroy; Begin end; constructor TGZ_Extractor.create(AOwner: TComponent); begin inherited create(AOwner); end; end.