home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 37 / hot37.iso / FICHEROS / 9TOOL / ADDZIP.ZIP / DELPHI / ADDZIPU.PAS < prev    next >
Pascal/Delphi Source File  |  1998-02-01  |  5KB  |  172 lines

  1. unit AddZipU;
  2.  
  3. interface
  4.  
  5. uses
  6. {$IFDEF WIN32}
  7.   Windows, SysUtils;
  8. {$ELSE}
  9.   WinTypes, WinProcs, SysUtils;
  10. {$ENDIF}
  11.  
  12. {
  13. addzipu.pas - addZip utility functions
  14.  
  15. Borland Delphi interface unit for addZIP compression libraries
  16. Copyright ⌐ 1995,1997 Stephen Darlington. All rights reserved.
  17.  
  18. Borland Delphi interface unit created by Brad Clarke.
  19. }
  20. Function GetPiece (from, delim : String; Index : Integer) : String;
  21. Function GetAction (cFrom : String) : String;
  22. Function GetFileCompressedSize (cFrom : String) : LongInt;
  23. Function GetFileCompressionRatio (cFrom : String) : String;
  24. Function GetViewFileName (cFrom : String) : String;
  25. Function GetFileOriginalSize (cFrom : String) : LongInt;
  26. Function GetFilePath (cFrom : String) : String;
  27. Function GetFileDate (cFrom : String) : String;
  28. Function GetFileTime (cFrom : String) : String;
  29. Function GetCompFileName (cFrom : String) : String;
  30. Function GetPercentComplete (cFrom : String) : String;
  31.  
  32. implementation
  33.  
  34. {****************************************************************************}
  35. {*************************** generic functions ******************************}
  36. {****************************************************************************}
  37.  
  38. { Text Parser }
  39. Function GetPiece (from, delim : String; Index : Integer) : String;
  40. var
  41.    Temp : String;
  42.    Count, Where : Integer;
  43. begin
  44.    Temp := from + delim;
  45.    Where := Pos(delim, Temp);
  46.    Count := 0;
  47.  
  48.    While Where > 0 do
  49.       begin
  50.          Count := Count + 1;
  51.          If Count = Index Then
  52.             begin
  53.                GetPiece := Copy(Temp, 0, (Where - 1));
  54.                Exit;
  55.             End;
  56.          Temp := Copy(Temp, Where  + 1, (Length(Temp) - Where));
  57.          Where := Pos(delim, Temp);
  58.        end;
  59.  
  60.    If Count = 0 Then
  61.       GetPiece := from
  62.    Else
  63.       GetPiece := '';
  64.  
  65. End;
  66.  
  67. { Determines the action currently in progress }
  68. Function GetAction (cFrom : String) : String;
  69. begin
  70.    GetAction := GetPiece(cFrom, '|', 2);
  71. End;
  72.  
  73. {****************************************************************************}
  74. {*************************** viewing functions ******************************}
  75. {****************************************************************************}
  76.  
  77. { Used while viewing archive contents }
  78. Function GetFilePath (cFrom : String) : String;
  79. begin
  80.    {$IFDEF USE_CALLBACKS}
  81.    GetFilePath := GetPiece(cFrom, '|', 2);
  82.    {$ELSE}
  83.    GetFilePath := GetPiece(cFrom, '|', 4);
  84.    {$ENDIF}
  85. End;
  86.  
  87. { Used while viewing archive contents }
  88. Function GetViewFileName (cFrom : String) : String;
  89. begin
  90.    {$IFDEF USE_CALLBACKS}
  91.    GetViewFileName := GetPiece(cFrom, '|', 3);
  92.    {$ELSE}
  93.    GetViewFileName := GetPiece(cFrom, '|', 5);
  94.    {$ENDIF}
  95. End;
  96.  
  97. { Used while viewing archive contents }
  98. Function GetFileOriginalSize (cFrom : String) : LongInt;
  99. begin
  100.    {$IFDEF USE_CALLBACKS}
  101.    GetFileOriginalSize := StrToInt(GetPiece(cFrom, '|', 4));
  102.    {$ELSE}
  103.    GetFileOriginalSize := StrToInt(GetPiece(cFrom, '|', 6));
  104.    {$ENDIF}
  105. End;
  106.  
  107. { Used while viewing archive contents }
  108. Function GetFileCompressedSize (cFrom : String) : LongInt;
  109. begin
  110.    {$IFDEF USE_CALLBACKS}
  111.    GetFileCompressedSize := StrToInt(GetPiece(cFrom, '|', 5));
  112.    {$ELSE}
  113.    GetFileCompressedSize := StrToInt(GetPiece(cFrom, '|', 7));
  114.    {$ENDIF}
  115. End;
  116.  
  117. { Used while viewing archive contents }
  118. Function GetFileCompressionRatio (cFrom : String) : String;
  119. begin
  120.    {$IFDEF USE_CALLBACKS}
  121.    GetFileCompressionRatio := GetPiece(cFrom, '|', 6);
  122.    {$ELSE}
  123.    GetFileCompressionRatio := GetPiece(cFrom, '|', 8);
  124.    {$ENDIF}
  125. End;
  126.  
  127. { Used while viewing archive contents }
  128. Function GetFileDate (cFrom : String) : String;
  129. begin
  130.    {$IFDEF USE_CALLBACKS}
  131.    GetFileDate := GetPiece(cFrom, '|', 7);
  132.    {$ELSE}
  133.    GetFileDate := GetPiece(cFrom, '|', 9);
  134.    {$ENDIF}
  135. End;
  136.  
  137. { Used while viewing archive contents }
  138. Function GetFileTime (cFrom : String) : String;
  139. begin
  140.    {$IFDEF USE_CALLBACKS}
  141.    GetFileTime := GetPiece(cFrom, '|', 8);
  142.    {$ELSE}
  143.    GetFileTime := GetPiece(cFrom, '|', 10);
  144.    {$ENDIF}
  145. End;
  146.  
  147. {****************************************************************************}
  148. {*************** compression / decompression functions **********************}
  149. {****************************************************************************}
  150.  
  151. { Used while zipping or unzipping archive contents }
  152. Function GetCompFileName (cFrom : String) : String;
  153. begin
  154.    {$IFDEF USE_CALLBACKS}
  155.    GetCompFileName := GetPiece(cFrom, '|', 2);
  156.    {$ELSE}
  157.    GetCompFileName := GetPiece(cFrom, '|', 4);
  158.    {$ENDIF}
  159. End;
  160.  
  161. { Used while zipping or unzipping archive contents }
  162. Function GetPercentComplete (cFrom : String) : String;
  163. begin
  164.    {$IFDEF USE_CALLBACKS}
  165.    GetPercentComplete := GetPiece(cFrom, '|', 5);
  166.    {$ELSE}
  167.    GetPercentComplete := GetPiece(cFrom, '|', 7);
  168.    {$ENDIF}
  169. End;
  170.  
  171. end.
  172.