home *** CD-ROM | disk | FTP | other *** search
- unit AddZipU;
-
- interface
-
- uses
- {$IFDEF WIN32}
- Windows, SysUtils;
- {$ELSE}
- WinTypes, WinProcs, SysUtils;
- {$ENDIF}
-
- {
- addzipu.pas - addZip utility functions
-
- Borland Delphi interface unit for addZIP compression libraries
- Copyright ⌐ 1995,1997 Stephen Darlington. All rights reserved.
-
- Borland Delphi interface unit created by Brad Clarke.
- }
- Function GetPiece (from, delim : String; Index : Integer) : String;
- Function GetAction (cFrom : String) : String;
- Function GetFileCompressedSize (cFrom : String) : LongInt;
- Function GetFileCompressionRatio (cFrom : String) : String;
- Function GetViewFileName (cFrom : String) : String;
- Function GetFileOriginalSize (cFrom : String) : LongInt;
- Function GetFilePath (cFrom : String) : String;
- Function GetFileDate (cFrom : String) : String;
- Function GetFileTime (cFrom : String) : String;
- Function GetCompFileName (cFrom : String) : String;
- Function GetPercentComplete (cFrom : String) : String;
-
- implementation
-
- {****************************************************************************}
- {*************************** generic functions ******************************}
- {****************************************************************************}
-
- { Text Parser }
- Function GetPiece (from, delim : String; Index : Integer) : String;
- var
- Temp : String;
- Count, Where : Integer;
- begin
- Temp := from + delim;
- Where := Pos(delim, Temp);
- Count := 0;
-
- While Where > 0 do
- begin
- Count := Count + 1;
- If Count = Index Then
- begin
- GetPiece := Copy(Temp, 0, (Where - 1));
- Exit;
- End;
- Temp := Copy(Temp, Where + 1, (Length(Temp) - Where));
- Where := Pos(delim, Temp);
- end;
-
- If Count = 0 Then
- GetPiece := from
- Else
- GetPiece := '';
-
- End;
-
- { Determines the action currently in progress }
- Function GetAction (cFrom : String) : String;
- begin
- GetAction := GetPiece(cFrom, '|', 2);
- End;
-
- {****************************************************************************}
- {*************************** viewing functions ******************************}
- {****************************************************************************}
-
- { Used while viewing archive contents }
- Function GetFilePath (cFrom : String) : String;
- begin
- {$IFDEF USE_CALLBACKS}
- GetFilePath := GetPiece(cFrom, '|', 2);
- {$ELSE}
- GetFilePath := GetPiece(cFrom, '|', 4);
- {$ENDIF}
- End;
-
- { Used while viewing archive contents }
- Function GetViewFileName (cFrom : String) : String;
- begin
- {$IFDEF USE_CALLBACKS}
- GetViewFileName := GetPiece(cFrom, '|', 3);
- {$ELSE}
- GetViewFileName := GetPiece(cFrom, '|', 5);
- {$ENDIF}
- End;
-
- { Used while viewing archive contents }
- Function GetFileOriginalSize (cFrom : String) : LongInt;
- begin
- {$IFDEF USE_CALLBACKS}
- GetFileOriginalSize := StrToInt(GetPiece(cFrom, '|', 4));
- {$ELSE}
- GetFileOriginalSize := StrToInt(GetPiece(cFrom, '|', 6));
- {$ENDIF}
- End;
-
- { Used while viewing archive contents }
- Function GetFileCompressedSize (cFrom : String) : LongInt;
- begin
- {$IFDEF USE_CALLBACKS}
- GetFileCompressedSize := StrToInt(GetPiece(cFrom, '|', 5));
- {$ELSE}
- GetFileCompressedSize := StrToInt(GetPiece(cFrom, '|', 7));
- {$ENDIF}
- End;
-
- { Used while viewing archive contents }
- Function GetFileCompressionRatio (cFrom : String) : String;
- begin
- {$IFDEF USE_CALLBACKS}
- GetFileCompressionRatio := GetPiece(cFrom, '|', 6);
- {$ELSE}
- GetFileCompressionRatio := GetPiece(cFrom, '|', 8);
- {$ENDIF}
- End;
-
- { Used while viewing archive contents }
- Function GetFileDate (cFrom : String) : String;
- begin
- {$IFDEF USE_CALLBACKS}
- GetFileDate := GetPiece(cFrom, '|', 7);
- {$ELSE}
- GetFileDate := GetPiece(cFrom, '|', 9);
- {$ENDIF}
- End;
-
- { Used while viewing archive contents }
- Function GetFileTime (cFrom : String) : String;
- begin
- {$IFDEF USE_CALLBACKS}
- GetFileTime := GetPiece(cFrom, '|', 8);
- {$ELSE}
- GetFileTime := GetPiece(cFrom, '|', 10);
- {$ENDIF}
- End;
-
- {****************************************************************************}
- {*************** compression / decompression functions **********************}
- {****************************************************************************}
-
- { Used while zipping or unzipping archive contents }
- Function GetCompFileName (cFrom : String) : String;
- begin
- {$IFDEF USE_CALLBACKS}
- GetCompFileName := GetPiece(cFrom, '|', 2);
- {$ELSE}
- GetCompFileName := GetPiece(cFrom, '|', 4);
- {$ENDIF}
- End;
-
- { Used while zipping or unzipping archive contents }
- Function GetPercentComplete (cFrom : String) : String;
- begin
- {$IFDEF USE_CALLBACKS}
- GetPercentComplete := GetPiece(cFrom, '|', 5);
- {$ELSE}
- GetPercentComplete := GetPiece(cFrom, '|', 7);
- {$ENDIF}
- End;
-
- end.
-