[delphizip] Re: OnSetAddName - remove file from the list

  • From: "Roger Aelbrecht" <Aelbrecr@xxxxxxxxxx>
  • To: <delphizip@xxxxxxxxxxxxx>
  • Date: Sat, 15 Jan 2005 14:58:18 +0100

Kiri Levente wrote:
> The idea is to use this event (or any ZipMaster event) to set the
> path and name of the files in the zip archive. I mean in my project
> the zipped files have completelly different path than the original
> disk paths, so i need a possibility to rename the files or even
> disable some of them.
> I found this event usefull because i have the ExtName parameter. In
> my case the option AddDirNames is not important at all because I
> simply ignore the FileName parameter and I rename the file.
> I've used ZipMaster 1.78
>
> 1. My First Solution: I've tried without AddDirnames. This is working
> because anyway i set the path, using the information from ExtName. It
> is also possible to set nothing to filename and the file is not added
> at all. Maybe it's a bug (very usefull in my case).
>
> What I found not very logic : i cannot add files with the same
> filename, even if i rename them.
> Probably you check the Filenames, why you don't check the renamed
> files to see if you have duplicate filenames ?
>
> Ex:
>
>  C:\My Files\duplicate.txt                         ->
> MyStorageFolder\duplicate.txt
>  C:\My Files\Folder\duplicate.txt              ->
> MyStorageFolder2\duplicate.txt
>  C:\My Files\Folder\todelete.txt               -> (nothing)
>
> -empty allowed
> -duplicate is not possible, because of duplicate filename.
>
> 2. My Second Solution: with AddDirnames
>
> Ex.
>
>  C:\My Files\duplicate.txt                         ->
> MyStorageFolder\duplicate.txt
>  C:\My Files\Folder\duplicate.txt              ->
> MyStorageFolder2\duplicate.txt
>  C:\My Files\Folder\todelete.txt                -> (nothing)
>
> - empty not allowed (Bad Zip Options)
> -duplicate is possible
>
> -------------
>
> Question: is there any possibilty to solve this problem ? An event to
> rename the files and to cancel some.
>
> KL
>
>

If you try to use it that way I strongly suggest to use AddDirNames
beause then the full path is used as the filename.

It is not ZipMaster that does not allow for duplicate filenames, it is
ZipDll.dll. As far as I know, Mr. R; Peeters will correct me,
the contorl for duplicate filenames is done while the dll is assembling
the list of files to add to the archive.
This means even before the real defalting and adding process begins,
in your first example you try to add duplicate.txt twice, that is not 
allowed.
Then when the dll is eeally adding the files to the archive the OnSetAddName
event is fired when the file will be added to the archive allowing to change 
the
filename in the archive to whatever you want.
At this momnet NO checking on the filename is done so you can enter
invalid filenames as well, but I don't know what the results will be.
QWhen entering an empty filename I have doubts that it is 'deleted', if it
is it is an unwanted side effect. I fear the file is invisible but the file 
is still
present in the archive.

It is not possible to exclude a file from adding to the archive in an event 
during
the adding process, that is simply not possible due to the way the dll 
works.
Remember the dll has to keep track of a lot of data for each file, later 
this
can be found in the LocalHeader, and the CentralHeader structures.
Removing a file is not as simple as deciding to add it or not, there are 
some
rather complex data structures involved.

If some files needs to be excluded from the archive that has to be specified 
in the
FSpecArgsExcl list.
Then the dll will exlude them from its list before the adding operation 
starts

HTH

-- 
Roger Aelbrecht
http://home.tiscali.be/driehoeksw



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.6.11 - Release Date: 12/01/2005

-----------
To unsubscribe from this list, send an empty e-mail 
message to:
  delphizip-request@xxxxxxxxxxxxx 
and put the word unsubscribe in the subject.

Other related posts: