Contents - Index - Previous - Next


RelativePathList property

 

Applies to

TVCLUnZip component

 

Declaration

property RelativePathList: TStrings;

 

Description

 

When Zipping: 

When storing relative path information using the RelativePaths Property, you must use this property to specify the directories from where path information will begin being saved.  See RelativePaths for more information on this topic.  Essentially the values in RelativePathList will be stripped from the saved path information. 

 

So if you put 'c:\somedir\*.*' into the FilesList and set RelativePathList.Add('c:\somedir') and set the Recurse property to True, then VCLZip Pro will store relative paths for all files from somedir on down through all subdirectories.  Files in somedir will have no path information stored, files in c:\somedir\subdir will only have subdir\ stored as path information and so on.

 

Adding multiple entries in RelativePathList allows you to create archives using RelativePaths from different anchor directories.  For instance if you had:

 

c:\one\dir1\file1

c:\one\dir2\file2

c:\one\dir3\file3

c:\two\dir1\file4

c:\two\dir2\file5

 

and you wanted to store files in the archive like:

 

dir1\file1

dir1\file4

dir2\file2

dir2\file5

dir3\file3

 

then you can add the following to RelativePathList:

 

RelativePathList.Add('c:\one');

RelativePathLIst.Add('c:\two');

 

which essentially takes the left part of the path of each file and looks for any matches int the entries in RelativePathList. If so, the matching string in RelativePathList is stripped from the path of the file being zipped. 

 

When UnZipping: 

Using the RelativePathList when unzipping allows you to extract files from an archive that was not created using the relative paths option and still treat it as though it was.  In this case you should set values in RelativePathList to the values that you want stripped from the internal path information for each file that is unzipped.  For instance, if you had an archive containing the following information:  

 

Filename Path Info  

file1.txt backups\subdir1\ 

file2.txt backups\subdir1\subdir2\ 

file3.txt backups\subdir1\subdir3\ 

 

and you wished to extract these files to a DestDir of c:\restore\ and retain the directory structure, normally you would end up with something like the following being extracted:  

 

c:\restore\backups\subdir1\file1.txt 

c:\restore\backups\subdir1\subdir2\file2.txt 

c:\restore\backups\subdir1\subdir3\file3.txt 

 

when what you really wanted was:

  

c:\restore\subdir1\file1.txt 

c:\restore\subdir1\subdir2\file2.txt 

c:\restore\subdir1\subdir3\file3.txt 

 

You can produce the desired results simply by setting  

 

RelativePathList.Add('backups\');  

 

before extracting.  What this does is effectively strip 'backups\' from the internal path information of each file prior to extracting.  Remember that you should set RootDir according to how the path information is stored in the archive.  Do not begin it with a '\' character and if the path information includes disk information then you should include that also. 

 

Note that if RootDir is not a substring of the internal path information then this action will not happen.