Autor Beitrag
DelphiNoobCoder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 98

Win XP SP1

BeitragVerfasst: Di 07.11.06 17:27 
Hi bin erst neu bei Delphi und wolte ein Game Updater erstellen bloß find ich nicht den Code der zip dateien entpackt. Kann wer PLS ein Code posten mit der dazugehörigen dll da ich schon sehr lange such und ich heute eigentlich fertig werden will wer echt nett.
DelphiNoobCoder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 98

Win XP SP1

BeitragVerfasst: Di 07.11.06 19:53 
So hab jetzt nen code bloß jetzt kommt nen public fehler

ausblenden volle Höhe C#-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:
53:
54:
public static void zip(String[] update.zip, String ./data/) {

         try {

             ZipOutputStream out = new ZipOutputStream(new FileOutputStream(./data/));
             byte[] buffer = new byte[BUFFERSIZE];
             int anz;
             for (int i = 0; i < dateien.length; i++) {

                 boolean wieder = false;

                 for (int j = 0; j < i; j++)
                     if (dateien[j].equals(dateien[i]))
                         wieder = true;

                 if (!wieder) {

                     BufferedInputStream in = new BufferedInputStream(new
                             FileInputStream(dateien[i]), BUFFERSIZE);
                     out.putNextEntry(new ZipEntry(update.zip[i]));

                     while ((anz = in.read(buffer)) != -1)
                         out.write(buffer, 0, anz);

                     in.close();
                     out.closeEntry();

                 }
             }

             out.close();

         } catch (IOException e) {}

     }
     
     
     
     
     
     
     ________________________________________________________________________
     public static InputStream entzippen(String update.zip, String ./data/) {

         try {

             ZipFile file = new ZipFile(update.zip);
             ZipEntry entry = file.getEntry(./data/);
             return file.getInputStream(entry);

         } catch (IOException e) { }

         return null;
     }


und was ich noch machen muss bin mir nicht sicher hab unzip32.dll den code und oben hab ich bei uses das stehen

ausblenden Delphi-Quelltext
1:
2:
3:
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, WinInet, ExtCtrls, jpeg, ShellAPI, ComCtrls, Buttons, unzip;


Moderiert von user profile iconChristian S.: Delphi- durch C#-Tags ersetzt
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 07.11.06 19:56 
Hallo und :welcome: in der Entwickler-Ecke!

Dass der Code nicht funktioniert, könnte unter Umständen daran liegen, dass das kein Delphi-Code ist.

Ich kenn mich mit anderen Programmiersprachen nicht so aus, würde hier aber spontan auf C++ tippen.

_________________
We are, we were and will not be.
DelphiNoobCoder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 98

Win XP SP1

BeitragVerfasst: Di 07.11.06 20:01 
Erstmal THX für die schnelle antwort
also könnte ich mit C++(z.B.) die datei erstellen und mit Delphi ausrufen das probier ich mal aus^^

Edit: Naja also C++ isses nicht schade

Also hier neuer Code neues glück

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:
53:
procedure Compress(InputFileName, OutputFileName: string);
var InputStream, OutputStream: TFileStream;
  CompressionStream: ZLib.TCompressionStream;
begin
  InputStream:=TFileStream.Create(InputFileName, fmOpenRead);
  try
    OutputStream:=TFileStream.Create(OutputFileName, fmCreate);
    try
      CompressionStream:=TCompressionStream.Create(clMax, OutputStream);
      try
        CompressionStream.CopyFrom(InputStream, InputStream.Size);
      finally
        CompressionStream.Free;
      end;
    finally
      OutputStream.Free;
    end;
  finally
    InputStream.Free;
  end;
end;
Entpacken:

procedure Decompress(InputFileName, OutputFileName: string);
var InputStream, OutputStream: TFileStream;
  DeCompressionStream: ZLib.TDeCompressionStream;
  Buf: array[0..4095] of Byte;
  Count: Integer;
begin
  InputStream:=TFileStream.Create(InputFileName, fmOpenRead);
  try
    OutputStream:=TFileStream.Create(OutputFileName, fmCreate);
    try
      DecompressionStream := TDecompressionStream.Create(InputStream);
      try
        while true do
        begin
          Count := DecompressionStream.Read(Buf[0], SizeOf(Buf));
          if Count = 0 then
            break
          else
            OutputStream.Write(Buf[0], Count);
        end;
      finally
        DecompressionStream.Free;
      end;
    finally
      OutputStream.Free;
    end;
  finally
    InputStream.Free;
  end;
end;


Wo komm hier der Filename in meiner fassung updater.zip rein?
Sinspin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1343
Erhaltene Danke: 121

Win 10
RIO, CE, Lazarus
BeitragVerfasst: Di 07.11.06 21:13 
Ich denke einmal das es JAVA ist was du da hast denn genau das beispiel habe ich bei mir rumfliegen.
falls du was suchst um zip's auf zu bekommen kann ich nur sagen nimm 7zip und sprich es über ShellExecute an oder befass dich mit der Delphi Bib. Suche in: Delphi-Forum, Delphi-Library ZIPMASTER.
mit dem javaprog kommst du jedenfalls nicht weiter denn in Delphi gibt es die verwendeten klassen nicht.

_________________
Wir zerstören die Natur und Wälder der Erde. Wir töten wilde Tiere für Trophäen. Wir produzieren Lebewesen als Massenware um sie nach wenigen Monaten zu töten. Warum sollte unser aller Mutter, die Natur, nicht die gleichen Rechte haben?
Sinspin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1343
Erhaltene Danke: 121

Win 10
RIO, CE, Lazarus
BeitragVerfasst: Di 07.11.06 21:15 
Interessantes tool das du da hast!
nun bei der denkompression sicherlich:
ausblenden Delphi-Quelltext
1:
procedure Decompress(InputFileName, OutputFileName: string);					

also bei InputFileName. denn beim dekomprimieren geht es ja darum das zip zu entpacken also ist es der input.

_________________
Wir zerstören die Natur und Wälder der Erde. Wir töten wilde Tiere für Trophäen. Wir produzieren Lebewesen als Massenware um sie nach wenigen Monaten zu töten. Warum sollte unser aller Mutter, die Natur, nicht die gleichen Rechte haben?