Recent

Author Topic: [Solved] The second file is cannot writing to TFileStream  (Read 2373 times)

drschwarcz

  • New Member
  • *
  • Posts: 17
[Solved] The second file is cannot writing to TFileStream
« on: July 11, 2014, 10:35:26 pm »
Hello Everybody,

I want to decompress a compressed file which contains some file. I can extract the first compressed file from archive, but the second one is empty yet.

Extract from my code:

for i := 1 to c do
      begin
{ read filename }

        s := '';
        infile.Read(l, 4);

        j := 1;

        while j <= l do
          begin

            Seged := #0;
            infile.Read(Seged, 1);
            s := s + Seged;
            Inc(j);

          end;
{ read original filesize }

        infile.Read(l, 4);
//Compressed filesize.

        infile.Read(k, 4);
        k := k + infile.Position;
{ decompress the files and store it }

        s := dest + AnsiToUTF8(s); //include the path

        outfile := TFileStream.Create(s,fmCreate + fmopenwrite);
        outfile.Position:= 0;

        SegedBuffer := 0;

        while outfile.size < l do
          begin

            SegedBuffer :=decompr.read(buffer, 4096);
            outfile.WriteBuffer(buffer, SegedBuffer);

          end;


        infile.Position:=k;

        outfile.Free;

      end;


What is wrong? (under Windows)

THX.
« Last Edit: July 12, 2014, 12:34:19 am by drschwarcz »
Lazarus 1.6.4 @ Windows 10 x64

Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe.

Einstein, Albert :) ;)

drschwarcz

  • New Member
  • *
  • Posts: 17
Re: The second file is cannot writing to TFileStream
« Reply #1 on: July 12, 2014, 12:22:47 am »
I try to solve it and I found the next:

The isseu is in the reading yet. The result of the second decompression (SegedBuffer) is 0, but I checked the compressed file and this is right.

I use the ZStream for the compression. Maybe, It is not supported more that one file in one compressed file.

Does anybody have experience with ZStream unit?


I solve it! :)

DecompressionStream is needed to define again (Create) each main loop (for to do).

decompr := TDecompressionStream.Create(infile);
« Last Edit: July 12, 2014, 12:31:52 am by drschwarcz »
Lazarus 1.6.4 @ Windows 10 x64

Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe.

Einstein, Albert :) ;)

 

TinyPortal © 2005-2018