Contents - Index - Previous - Next
RootDir property
Applies to
TVCLUnZip component
Declaration
property RootDir: string;
Description
When Zipping:
The RootDir property determines where zipping will start for any wildcard entries or filenames in the FilesList Property that do not already include path information. Essentially, the value of RootDir will be prepended to anything in the FilesList that does not have any path information when zipping.
Also, when storing relative path information using the RelativePaths Property, you must use this RootDir property to specify the directory from where path information will begin being saved. See RelativePaths for more information on this topic. Essentially the value of RootDir will be stripped from the saved path information in this case.
When UnZipping:
Using the RootDir 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 RootDir to the value 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\backups and retain the directory structure, normally you would end up with something like the following being extracted:
c:\restore\backups\backups\subdir1\file1.txt
c:\restore\backups\backups\subdir1\subdir2\file2.txt
c:\restore\backups\backups\subdir1\subdir3\file3.txt
when what you really wanted was:
c:\restore\backups\subdir1\file1.txt
c:\restore\backups\subdir1\subdir2\file2.txt
c:\restore\backups\subdir1\subdir3\file3.txt
You can produce the desired results simply by setting
RootDir := 'backups\subdir1\';
before extracting. What this does is effectively strip 'backups\subdir1\' 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.