Search code examples
delphizipdelphi-2007unzipvclzip

VCLZip: Ask if readonly files should be overwritten


I'm using VCLZip 2.21 to unzip a zip file. I can make TVCLUnzip overwrite readonly files by setting ReplaceReadOnly to True. But how do I implement a confirmation by the user? I already added an OnSkippingFile handler setting Retry to True but this doesn't result in an additional try. (AFAICT the Retry variable is never read.) Do you have any advice?


Solution

  • It seems to me that you shouldn't change ReplaceReadOnly. Instead, set OverwriteMode to Prompt, and then handle the OnPromptForOverwrite event. In that event, check whether the file is read-only, and only prompt if it is.

    Otherwise, you could try changing the read-only flag of a file in the OnSkippingFile event handler before setting Retry, but the documentation doesn't say the Retry parameter is used in that situation. It only talks about retrying during zipping operations where it couldn't open the to-be-zipped file, not during unzipping operations.