Contents - Index - Previous - Next


RelativePaths property

 

Applies to

TVCLZip component

 

Declaration

property RelativePaths: Boolean;

 

Description

The RelativePaths property should be set to True if you wish to save path information but only wish to save path information relative to a specified directory.  The only path information that is saved is for subdirectories below the specified directory.  This is similar to the Relative Path option of PKZip for Windows. 

 

Whenever you set RelativePaths property to True, the Recurse Property and the StorePaths Property are automatically set to True also.  Likewise, if the StorePaths Property is set to False, then the RelativePaths Property is automatically set to False also.  

 

You would normally use a wildcard to specify files to be zipped, but you may also add specific files to the FilesList as long as they are within the directory tree of the RootDir.  

 

If you add to, or replace files in, an existing archive which was created with the relative path option you should set the RootDir property to the same value that was used when the archive was created before calling the Zip method.  

When storing relative paths it is NECESSARY to use the RootDir Property to specify the directory in which to start the recursive search for files to compare to some wildcard filespec.  Here is an example of using the RelativePaths property: 

 

With VCLZip1 do 

begin 

ZipName := 'c:\backups\MyArchive.Zip'; 

RootDir := 'c:\develop\myprog\'; /* Set the starting directory */ 

FilesList.Add('*.pas'); /* Don't include path here */ 

RelativePaths := True; /* Specify Relative Paths - sets StorePaths & Recurse to True also*/ 

Zip; 

end; 

 

Say the directory structure looks something like the following:  

\develop\myprog 

\develop\myprog\help 

\develop\myprog\examples 

\develop\myprog\proj 

\develop\myprog\proj\save

 

Files zipped from each of these directories will have the following path information stored depending on how RelativePaths is set: 

 

RelativePaths = False RelativePaths = True 

develop\myprog\ None Saved  

develop\myprog\help\ help\ 

develop\myprog\examples\ examples\ 

develop\myprog\proj\ proj\ 

develop\myprog\proj\save\ proj\save\