home *** CD-ROM | disk | FTP | other *** search
/ Intermedia 1998 January / inter1_98.iso / www / rozi / ZIPV.ZIP / ZIPV.PAS < prev   
Pascal/Delphi Source File  |  1997-09-14  |  9KB  |  345 lines

  1. {
  2. Author: Steve Wierenga
  3. ZIP Viewer
  4. }
  5.  
  6. Unit ZipV;
  7.  
  8. (**) Interface (**)
  9.  
  10. Uses
  11.   Dos,Crt;
  12. Procedure ZipView(ZIPFile:String);
  13. Function GAN(ZIPFile : String) : String;
  14.  
  15. (**) Implementation (**)
  16.  
  17. Procedure Terminate;
  18. begin
  19.   Write('ARCHPEEK could not find specified File. Aborting...');
  20.   Halt;
  21. end;
  22.  
  23. Procedure ZipView(ZIPFile : String);  { View the ZIP File }
  24. Const
  25.   SIG = $04034B50;                  { Signature }
  26. Type
  27.   ZFHeader = Record                 { Zip File Header }
  28.     Signature  : LongInt;
  29.     Version,
  30.     GPBFlag,
  31.     Compress,
  32.     Date,Time  : Word;
  33.     CRC32,
  34.     CSize,
  35.     USize      : LongInt;
  36.     FNameLen,
  37.     ExtraField : Word;
  38.   end;
  39.  
  40. Var
  41.   z       : Integer;
  42.   x,
  43.   totalu,
  44.   totalc  : LongInt;
  45.   Hdr     : ^ZFHeader;
  46.   F       : File;
  47.   S,sss   : String;
  48.   own     : Text;
  49.   dt1     : DateTime;
  50.   l       : String[80];
  51.   registered : Boolean;  { Is registered? }
  52.  
  53. Const
  54.   CompTypes : Array[0..7] of String[9] =
  55.               ('Stored ','Shrunk   ','Reduced1','Reduced2','Reduced3',
  56.                'Reduced4','Imploded ','Deflated');
  57.   { Method used to compress }
  58.   r = #196;
  59.   q = #205;
  60.  
  61. begin
  62.   z := 0; totalu := 0; totalc := 0; { Init Variables }
  63.   registered := False; { Unregistered }
  64.   if not registered then   { Is registered? }
  65.   begin
  66.     Writeln('ArchPeek 0.01Alpha [UNREGISTERED] Copyright 1993 Steve Wierenga');
  67.     Delay(200);
  68.   end;
  69.   New(Hdr);
  70.   Assign(F,ZIPFile);
  71.   {$I-}
  72.   Reset(F,1);                   { Open File }
  73.   {$I+}
  74.   If IOResult <> 0 then Terminate;  { Couldn't open Zip File }
  75.   sss := GAN(ZipFile);              { Get the Zip Filename }
  76.   Writeln('Zip FileName: ',sss);
  77.   WriteLn( '   Name           Length      Size  Saved Method');
  78.   WriteLn(r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,
  79.           r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r);
  80.   Repeat
  81.     FillChar(S,SizeOf(S), #0);  { Pad With nulls }
  82.     BlockRead(F,Hdr^,SizeOf(ZFHeader));
  83.     { Read File Header }
  84.     BlockRead(F,Mem[Seg(S) : Ofs(S) + 1], Hdr^.FNameLen);
  85.     s[0] := Chr(Hdr^.FNameLen);
  86.     Case Length(S) Of    { Straighten String }
  87.      0  : s := s + '            ';
  88.      1  : S := s + '           ';
  89.      2  : s := s + '          ';
  90.      3  : S := S + '         ';
  91.      4  : S := S + '        ';
  92.      5  : S := S + '       ';
  93.      6  : S := S + '      ';
  94.      7  : S := S + '     ';
  95.      8  : S := S + '    ';
  96.      9  : S := S + '   ';
  97.      10 : S := S + '  ';
  98.      11 : S := S + ' ';
  99.      12 : S := S;
  100.     end;
  101.       If (Hdr^.Signature = Sig) Then { Is a header }
  102.     begin
  103.       z := z + 1;
  104.       WriteLn(S,Hdr^.USize:9,Hdr^.CSize:10,(100-Hdr^.CSize/Hdr^.USize*100):5:0,'%',
  105.               CompTypes[Hdr^.Compress]:16);
  106.       Inc(TotalU,Hdr^.USize);  { Increment size uncompressed }
  107.       Inc(TotalC,Hdr^.CSize);  { Increment size compressed }
  108.     end;
  109.     Seek(F,FilePos(F) + Hdr^.CSize + Hdr^.ExtraField);
  110.   Until Hdr^.Signature <> SIG; { No more Files }
  111.   GetFTime(F,x);
  112.   UnPackTime(x,DT1);
  113.   WriteLn(q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,
  114.           q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q);
  115.   Write( z:4,' Files ',TotalU:12,TotalC:10,(100-TotalC/TotalU*100):5:0,'%');
  116.   Case dt1.month of        { Get Zip File date and time }
  117.     1..9   : Write( '0':4,dt1.month);
  118.     10..12 : Write( dt1.month:4);
  119.   end;
  120.   Write( '/');
  121.   Case dt1.day of
  122.     1..9   : Write( '0',dt1.day);
  123.     10..31 : Write( dt1.day);
  124.   end;
  125.   Write( '/');
  126.   Case dt1.year of
  127.     1980 : Write( '80');
  128.     1981 : Write( '81');
  129.     1982 : Write( '82');
  130.     1983 : Write( '83');
  131.     1984 : Write( '84');
  132.     1985 : Write( '85');
  133.     1986 : Write( '86');
  134.     1987 : Write( '87');
  135.     1988 : Write( '88');
  136.     1989 : Write( '89');
  137.     1990 : Write( '90');
  138.     1991 : Write( '91');
  139.     1992 : Write( '92');
  140.     1993 : Write( '93');
  141.     1994 : Write( '94');
  142.     1995 : Write( '95');
  143.     1996 : Write( '96');
  144.   end;
  145.   Case dt1.hour of
  146.     0..9   : Write( '0':3,dt1.hour,':');
  147.     10..23 : Write( dt1.hour:3,':');
  148.   end;
  149.   Case dt1.min of
  150.     0..9   : Write( '0',dt1.min,':');
  151.     10..59 : Write( dt1.min,':');
  152.   end;
  153.   Case dt1.sec of
  154.     0..9   : Writeln( '0',dt1.sec);
  155.     10..59 : Writeln( dt1.sec);
  156.   end;
  157.   Close(F);
  158.   Dispose(Hdr);
  159. end;
  160.  
  161.  
  162. Function GAN(ZIPFile:String): String;
  163. Var
  164.   Dir  : DirStr;
  165.   Name : NameStr;
  166.   Exts : ExtStr;
  167. begin
  168.   FSplit(ZIPFile,Dir,Name,Exts);
  169.   GAN := Name + Exts;
  170. end;
  171.  
  172. end.
  173. {
  174. Author: Steve Wierenga
  175. ZIP Viewer
  176. }
  177.  
  178. Unit ZipV;
  179.  
  180. (**) Interface (**)
  181.  
  182. Uses
  183.   Dos,Crt;
  184. Procedure ZipView(ZIPFile:String);
  185. Function GAN(ZIPFile : String) : String;
  186.  
  187. (**) Implementation (**)
  188.  
  189. Procedure Terminate;
  190. begin
  191.   Write('ARCHPEEK could not find specified File. Aborting...');
  192.   Halt;
  193. end;
  194.  
  195. Procedure ZipView(ZIPFile : String);  { View the ZIP File }
  196. Const
  197.   SIG = $04034B50;                  { Signature }
  198. Type
  199.   ZFHeader = Record                 { Zip File Header }
  200.     Signature  : LongInt;
  201.     Version,
  202.     GPBFlag,
  203.     Compress,
  204.     Date,Time  : Word;
  205.     CRC32,
  206.     CSize,
  207.     USize      : LongInt;
  208.     FNameLen,
  209.     ExtraField : Word;
  210.   end;
  211.  
  212. Var
  213.   z       : Integer;
  214.   x,
  215.   totalu,
  216.   totalc  : LongInt;
  217.   Hdr     : ^ZFHeader;
  218.   F       : File;
  219.   S,sss   : String;
  220.   own     : Text;
  221.   dt1     : DateTime;
  222.   l       : String[80];
  223.   registered : Boolean;  { Is registered? }
  224.  
  225. Const
  226.   CompTypes : Array[0..7] of String[9] =
  227.               ('Stored ','Shrunk   ','Reduced1','Reduced2','Reduced3',
  228.                'Reduced4','Imploded ','Deflated');
  229.   { Method used to compress }
  230.   r = #196;
  231.   q = #205;
  232.  
  233. begin
  234.   z := 0; totalu := 0; totalc := 0; { Init Variables }
  235.   registered := False; { Unregistered }
  236.   if not registered then   { Is registered? }
  237.   begin
  238.     Writeln('ArchPeek 0.01Alpha [UNREGISTERED] Copyright 1993 Steve Wierenga');
  239.     Delay(200);
  240.   end;
  241.   New(Hdr);
  242.   Assign(F,ZIPFile);
  243.   {$I-}
  244.   Reset(F,1);                   { Open File }
  245.   {$I+}
  246.   If IOResult <> 0 then Terminate;  { Couldn't open Zip File }
  247.   sss := GAN(ZipFile);              { Get the Zip Filename }
  248.   Writeln('Zip FileName: ',sss);
  249.   WriteLn( '   Name           Length      Size  Saved Method');
  250.   WriteLn(r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,
  251.           r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r);
  252.   Repeat
  253.     FillChar(S,SizeOf(S), #0);  { Pad With nulls }
  254.     BlockRead(F,Hdr^,SizeOf(ZFHeader));
  255.     { Read File Header }
  256.     BlockRead(F,Mem[Seg(S) : Ofs(S) + 1], Hdr^.FNameLen);
  257.     s[0] := Chr(Hdr^.FNameLen);
  258.     Case Length(S) Of    { Straighten String }
  259.      0  : s := s + '            ';
  260.      1  : S := s + '           ';
  261.      2  : s := s + '          ';
  262.      3  : S := S + '         ';
  263.      4  : S := S + '        ';
  264.      5  : S := S + '       ';
  265.      6  : S := S + '      ';
  266.      7  : S := S + '     ';
  267.      8  : S := S + '    ';
  268.      9  : S := S + '   ';
  269.      10 : S := S + '  ';
  270.      11 : S := S + ' ';
  271.      12 : S := S;
  272.     end;
  273.       If (Hdr^.Signature = Sig) Then { Is a header }
  274.     begin
  275.       z := z + 1;
  276.       WriteLn(S,Hdr^.USize:9,Hdr^.CSize:10,(100-Hdr^.CSize/Hdr^.USize*100):5:0,'%',
  277.               CompTypes[Hdr^.Compress]:16);
  278.       Inc(TotalU,Hdr^.USize);  { Increment size uncompressed }
  279.       Inc(TotalC,Hdr^.CSize);  { Increment size compressed }
  280.     end;
  281.     Seek(F,FilePos(F) + Hdr^.CSize + Hdr^.ExtraField);
  282.   Until Hdr^.Signature <> SIG; { No more Files }
  283.   GetFTime(F,x);
  284.   UnPackTime(x,DT1);
  285.   WriteLn(q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,
  286.           q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q,q);
  287.   Write( z:4,' Files ',TotalU:12,TotalC:10,(100-TotalC/TotalU*100):5:0,'%');
  288.   Case dt1.month of        { Get Zip File date and time }
  289.     1..9   : Write( '0':4,dt1.month);
  290.     10..12 : Write( dt1.month:4);
  291.   end;
  292.   Write( '/');
  293.   Case dt1.day of
  294.     1..9   : Write( '0',dt1.day);
  295.     10..31 : Write( dt1.day);
  296.   end;
  297.   Write( '/');
  298.   Case dt1.year of
  299.     1980 : Write( '80');
  300.     1981 : Write( '81');
  301.     1982 : Write( '82');
  302.     1983 : Write( '83');
  303.     1984 : Write( '84');
  304.     1985 : Write( '85');
  305.     1986 : Write( '86');
  306.     1987 : Write( '87');
  307.     1988 : Write( '88');
  308.     1989 : Write( '89');
  309.     1990 : Write( '90');
  310.     1991 : Write( '91');
  311.     1992 : Write( '92');
  312.     1993 : Write( '93');
  313.     1994 : Write( '94');
  314.     1995 : Write( '95');
  315.     1996 : Write( '96');
  316.   end;
  317.   Case dt1.hour of
  318.     0..9   : Write( '0':3,dt1.hour,':');
  319.     10..23 : Write( dt1.hour:3,':');
  320.   end;
  321.   Case dt1.min of
  322.     0..9   : Write( '0',dt1.min,':');
  323.     10..59 : Write( dt1.min,':');
  324.   end;
  325.   Case dt1.sec of
  326.     0..9   : Writeln( '0',dt1.sec);
  327.     10..59 : Writeln( dt1.sec);
  328.   end;
  329.   Close(F);
  330.   Dispose(Hdr);
  331. end;
  332.  
  333.  
  334. Function GAN(ZIPFile:String): String;
  335. Var
  336.   Dir  : DirStr;
  337.   Name : NameStr;
  338.   Exts : ExtStr;
  339. begin
  340.   FSplit(ZIPFile,Dir,Name,Exts);
  341.   GAN := Name + Exts;
  342. end;
  343.  
  344. end.
  345.