Hi all,
Trying to decompress .bz2 files, but getting a stream read error.
(Note: I know there's an error in the Pascal bzip2 decompressor on i386; see bug 21242; I'm trying this with a x64 Linux compiler)
I've tried to chain the input file stream to the decompression stream, but I'm probably doing something wrong there. The code errors at the marked point.
Code:
var
InFile:TFileStream;
Decompressed:TDecompressBzip2Stream;
OutFile:TFileStream;
begin
result:=false;
InFile:=TFileStream.Create(SourceFile, fmOpenRead);
try
Decompressed:=TDecompressBzip2Stream.Create(InFile);
OutFile:=TFileStream.Create(TargetFile, fmCreate);
try
Decompressed.CopyFrom(InFile, InFile.Size); //error occurs here.
OutFile.CopyFrom(Decompressed, Decompressed.Size);
result:=true;
finally
Decompressed.Free;
OutFile.Free;
end;
finally
InFile.Free;
end;
Entire Lazarus program attached.
Thanks!