Autor Beitrag
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: So 21.09.03 11:49 
Hallo,
habe folgenden code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
function TMfa.GetFileHeader(S1:TStream):TStream;
var
  S:TStream;
  x,count:Integer;
  Str:String;
begin
  S:=TMemoryStream.Create;
  s1.seek(3,soFromBeginning);
  SetLength(str,3);
  while True do begin
    count:=S1.Read(Pchar(Str)^,3);

    if str = 'BZh' then begin
      ShowMessage('Test');
    end;

    if (x > 2) and (Str = 'BZh') then
      ShowMessage('"ffff' + STr);

    s1.seek(-3,soFromCurrent);
  end;
end;


diese code soll mir in einem stream etwas suchen und finden.
nun habe ich folgendes problem:
habe eine datei wo diese suchbergrief erstmal nur zwei mal vorkommt:
an position 0 und noch einmal etwas später.
und ich möchte gerne das was da zwischen steht soll in s eingelesen werden, aber das funktioniert irngendwie nicht so gans :( :(

_________________
MFG
Michael Springwald, "kann kein englisch...."
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: So 21.09.03 15:15 
habe die funktion nun geändernt:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
procedure TMFa.entpacktB;
const
  BufferSize = 65536;
var
  S1,CS,DS,DSH:TStream;
  Soruce:TStream;
  Count: Integer;
  Header:TStringList;
  Buffer: array[0..BufferSize - 1] of Byte;

begin
  S1:=TFileStream.Create(FileName,fmOpenRead or fmShareDenyNone);
  DSH:=TFileStream(TempVerzeichnis + 'Header.tmp');

  Soruce:=TMemoryStream.Create;
  DS:=TMemoryStream.Create;
  
  Header:=TStringList.Create;

  try
    Soruce.CopyFrom(GetFileHeader(S1),0);
    CS := TBZDecompressionStream.Create(Soruce);

    try
      while True do begin
        Count := CS.Read(Buffer, BufferSize);
        Showmessage(IntToStr(Count));
        if Count <> 0 then
          DS.WriteBuffer(Buffer, Count)
        else
          Break;
      end;
    finally
      CS.Free;
      end;
    DS.Position := 0;
  finally
//    DeleteFile(FileName);
//    RenameFile(FileName + '.tst1', FileName);

    DSH.CopyFrom(ds,0);
    S1.Free;
    DS.Free;

    DSH.Free;
    Soruce.Free;

  end;
end;

aber er entpackt die datei nicht. warum weiß das jemmand ?[/list]

_________________
MFG
Michael Springwald, "kann kein englisch...."
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 30.09.03 16:56 
ich habe die funktion nochmal verändern, aber ich schaffe es einfach nicht das die danten entpackt werden in Soruce steht das richtige drin. kann mir jemmand sagen, wie ich das problem am besten lösen kann ?
Achja, ich verwedne BZip2

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
procedure TMFa.entpacktB;
const
  BufferSize = 65536;
var
  S1,CS,DS,DSH:TStream;
  Soruce:TStream;
  Count: Integer;
//  Header:TStringList;
  Buffer: array[0..BufferSize - 1] of Byte;

begin
  S1:=TFileStream.Create(FileName,fmOpenRead or fmShareDenyNone);
//  DSH:=TFileStream.Create(TempVerzeichnis + 'Header151517.tmp',fmCreate);

  Soruce:=TFileStream.Create(TempVerzeichnis + 'Soruce2945.tmp',fmCreate);
  DS:=TFileStream.Create(TempVerzeichnis + 'DS0125.tmp',fmCreate);

//  Header:=TFileStream.Create(TempVerzeichnis + 'Header.tmp',fmCreate);

  try
    try
      Soruce.CopyFrom(GetFileHeader(S1),0);
    finally
      CS := TBZDecompressionStream.Create(Soruce);

      try
        while True do begin
          Count := CS.Read(Buffer, BufferSize);
          if Count <> 0 then
            DS.WriteBuffer(Buffer, Count)
          else
            Break;
        end;

      finally
        CS.Free;
      end;
      DS.Position := 0;
    end;
  finally
//    DeleteFile(FileName);
//    RenameFile(FileName + '.tst1', FileName);

//    DSH.CopyFrom(ds,0);
    S1.Free;
    DS.Free;

//    DSH.Free;
    Soruce.Free;

  end;
end;

_________________
MFG
Michael Springwald, "kann kein englisch...."
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Fr 03.10.03 16:44 
weiß keiner eine lösung ?
das problem bestehht leider immer noch :(

_________________
MFG
Michael Springwald, "kann kein englisch...."
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mi 15.10.03 17:37 
der vorletzte posting, von mir, beschreibt das problem, ich komme da einfach nicht mehr weiter. die datei ist null byte groß warum ???

_________________
MFG
Michael Springwald, "kann kein englisch...."
rokdd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 329

Win XP
D6
BeitragVerfasst: So 08.02.04 21:52 
hallo,
hast du das problem immer noch oder hat es sich erledigt(hatte glaube ich schon mal dasselbe problem und inzwischen ist es verschwunden ;-) )!

Rokdd
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: So 15.02.04 08:54 
das problem hat sich gelöst mit einem Stream.position:=0 :)

_________________
MFG
Michael Springwald, "kann kein englisch...."