ChangeFileComment()
Previous  Top  Next

:ChangeFileComment() - Change a specific (File) Entry's Comment/Note.

Syntax

:ChangeFileComment(<cEntry> | <nEntry> | <oEntry>,  
                   <cNewComment>) --> cOldComment  

Parameters

The first Parameter can be either a Character String, a Number, or a Central Directory Record Object:  

<cEntry>  
<cEntry> specifies the File Name of the Central Directory Record Entry that contains the information for the (File) Entry that should be changed in the Zip File.  
 
<nEntry>  
<nEntry> specifies the Index Number of the Central Directory Record Entry that contains the information for the (File) Entry that should be changed in the Zip File.  
 
<oEntry>  
<oEntry> specifies the ZipCentralDirectoryRecord object of the (File) Entry that should be changed in the Zip File.  
 
<cNewComment>  
<cNewComment> specifies the New (File) Comment for the existing Central Directory Record Entry.  

Returns

This method returns the previous, old, (File) Comment, or "" (an empty string), if the (File) Entry could not be found.  

Description

Changes the Comment of an existing (File) Entry's Central Directory Record in the Zip File, and returns the previous, old, Comment of the Entry.  
 
This Comment is usually completely ignored by most programs that add or extract (File) Entries from Zip Files, but can be displayed and/or updated, by many of them. In most cases, this Comment is simply an empty string, but it can be used to describe the Entry's purpose in some detail or to give specific extraction instructions. Comments are never compressed and are simply added to the Zip File's Central Directory, increasing the size of the Zip File by their combined length. The maximum length of any such comments is (0xFFFF) or 65535 characters.  

Example

Open an existing Zip File named "MyArchive.zip" and read its directory into an array. Then set the File Comments of all "*.dll" files to "Runtime Library", and the File Comments of all "*.dbf" files to "Database". Then save the changes and close the Zip File:  

oZip := XbZLibZip():New('MyArchive.zip')  
aDir := oZip:Directory()  
for nCount := 1 to len(aDir)  
   cExtension := upper(right(aDir[nCount]:FileName, 4))  
   if cExtension == '.DLL'  
      oZip:ChangeFileComment(aDir[nCount], 'Runtime Library')  
   elseif cExtension == '.DBF'  
      oZip:ChangeFileComment(aDir[nCount], 'Database')  
   endif  
next nCount  
oZip:Close()