Hello! I use the LZMA-SDK for Pascal to compress files. ( http://www.birtles.org.uk/programming/ ) I can compress files on 64bit and 32bit architecture. But if I try to decompress LZMA-Compressed files on AMD64, it fails. I use code [-1-] to decompress files. The action works perfectly on i386, but if I compile it for AMD64 usi9ng FPC 2.4.0 it fails throwing the exception 'Error in data stream'. It fails at code [-2-] in TLZMADecoder.Code because pos0 is greater than nowPos64. I'am trying now for about half a week to solve this problem, but I don't have any idea now, why this happens on AMD64. The code does not use any pointers which could be wrong, but maybe a type conversion from Int64 to Int32... Does anyone know why the code fails to work? Is this a bug in FPC? Kind regards Matthias Klumpp
################################################### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CodeSequence [-1-]: ----- var inStream:TBufferedFS; outStream:TBufferedFS; decoder: TLZMADecoder; properties:array[0..4] of byte; filesize,outSize:Int64; i: Integer; v: byte; const propertiessize=5; begin if not FileExists(ipkfile) then Exception.Create('IPK file does not exists!'); try inStream:=TBufferedFS.Create(ipkfile, fmOpenRead or fmShareDenyNone); try outStream:=TBufferedFS.Create(workdir+'ipktar.tar', fmCreate); decoder:=TLZMADecoder.Create; inStream.position:=0; with decoder do begin if inStream.read(properties, propertiesSize) <> propertiesSize then raise Exception.Create('input .lzma file is too short'); if not SetDecoderProperties(properties) then raise Exception.Create('Incorrect stream properties'); outSize := 0; for i := 0 to 7 do begin v := inStream.ReadByte; if v < 0 then raise Exception.Create('Can''t read stream size'); outSize := outSize or v shl (8 * i); end; if not Code(inStream, outStream, outSize) then raise Exception.Create('Error in data stream'); end; decoder.Free; finally outStream.Free; end; finally inStream.Free; end; end; ################################################### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CodeSequence [-2-]: ----- if (rep0 >= nowPos64) or (rep0 >= m_DictionarySizeCheck) then begin m_OutWindow.Flush(); result:=false; exit; end; ################################################### _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal