TEST3.PAS
Upload User: qxf5203344
Upload Date: 2021-08-05
Package Size: 101k
Code Size: 3k
Development Platform:

Delphi

  1. {
  2. Test program for unzip, using Delphi component/Pascal object
  3. }
  4. PROGRAM Test3;
  5. {$i unzip.inc}
  6. USES
  7. {$ifdef Windows}
  8. Winprocs,
  9. Wincrt,
  10. {$endif Windows}
  11. {$ifdef Delphi}
  12. Sysutils,
  13. {$else}
  14. Strings,
  15. {$endif Delphi}
  16. ZipTypes,
  17. ChfUnzip;
  18. {/////////////////////////////////////////////////////}
  19. PROCEDURE Report ( Retcode : longint;R : pReportRec );
  20. {$ifdef Windows}{$ifdef win32}STDCALL;{$else}EXPORT;{$endif}{$endif}
  21. BEGIN
  22.   WITH r^ DO
  23.   CASE Status of
  24.   file_completed :
  25.    Writeln
  26.    ( 
  27.    UnzipMethods [ packmethod ] : 9,
  28.    '  ', Size : 9,
  29.    '  ', CompressSize : 9,
  30.    '  ', Ratio : 5, '%',
  31.    '  ', filename
  32.    );
  33.    unzip_completed :
  34.    Writeln
  35.    ( 
  36.    'Archived' : 9,
  37.    '  ', Size : 9,
  38.    '  ', CompressSize : 9,
  39.    '  ', Ratio : 5, '%',
  40.    '  ', filename
  41.    );
  42.  END {case}
  43. END; {Report}
  44. {/////////////////////////////////////////////////////}
  45. PROCEDURE Report2 ( Retcode : longint;R : pReportRec );
  46. {$ifdef Windows}{$ifdef win32}STDCALL;{$else}EXPORT;{$endif}{$endif}
  47. BEGIN
  48.    WITH r^ DO
  49.    Writeln
  50.    ( 
  51.    UnzipMethods [ packmethod ] : 9,
  52.    '  ', Size : 9,
  53.    '  ', CompressSize : 9,
  54.    '  ', Ratio : 5, '%',
  55.    '  ', filename
  56.    );
  57. END; {Report2}
  58. {/////////////////////////////////////////////////////}
  59. {/////////////////////////////////////////////////////}
  60. VAR
  61. Zip : TChiefUnzip;
  62. i : integer;
  63. p : pchar;
  64. BEGIN
  65.   IF ( paramcount < 2 )
  66.   THEN BEGIN
  67.     getmem ( p, 512 );
  68.     strcopy ( p, 'Syntax=TEST3 <filename.ZIP> <[target dir] or [/v]> [specs]'#13#10#13#10 );
  69.     Strcat ( p, 'Examples: '#13#10 );
  70.     Strcat ( p, '    TEST3 TEST.ZIP C:TEMP'#13#10 );
  71.     Strcat ( p, '    TEST3 TEST.ZIP C:TEMP *.PAS'#13#10 );
  72.     Strcat ( p, '    TEST3 TEST.ZIP C:TEMP ZIP*.*'#13#10 );
  73.     Strcat ( p, '    TEST3 TEST.ZIP /V'#13#10 );
  74.     Strcat ( p, '    TEST3 TEST.ZIP /V *.EXE'#13#10 );
  75.   {$ifdef Windows}
  76.      Messagebox ( 0, p, 'Chief''s UNZIP', 0 );
  77.   {$else}
  78.      Writeln ( p );
  79.   {$endif}
  80.      freemem ( p, 512 );
  81.      halt;
  82.   END;
  83.   {$ifdef Windows}
  84.    WITH ScreenSize DO BEGIN
  85.         x := 75;
  86.         y := 500;
  87.    END;
  88.    WITH WindowOrg DO BEGIN
  89.         x := 1;
  90.         y := 1
  91.    END;
  92.   {$endif}
  93.   Zip{$ifndef ver70} := TChiefUnzip{$endif}.Create{$ifdef Delphi} ( NIL ) {$endif};
  94.   WITH Zip DO BEGIN
  95.      {$ifdef Delphi}
  96.        FileName := ParamStr ( 1 );
  97.        DirectoryName := ParamStr ( 2 );
  98.        FileSpecs := ParamStr ( 3 );
  99.        ReportProc := Report;
  100.      {$else}
  101.        SetFileName ( ParamStr ( 1 ) );
  102.        SetDirectoryName ( ParamStr ( 2 ) );
  103.        SetFileSpecs ( ParamStr ( 3 ) );
  104.        SetReportProc ( Report );
  105.      {$endif}
  106.        IF ( upper ( paramstr ( 2 ) ) = '/V' ) OR ( upper ( paramstr ( 2 ) ) = '-V' )
  107.        THEN BEGIN
  108.           SetReportProc ( Report2 );
  109.           i := View
  110.        END
  111.        ELSE i := Unzip;
  112.        Destroy;
  113.   END; {With Zip}
  114. END.