ChangeFileDateTime()
|
Previous Top Next |
:ChangeFileDateTime(<cEntry> | <nEntry> | <oEntry>,
|
[<dNewFileDate>],
|
[<cNewFileTime>]) --> aOldDateTime
|
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.
|
<dNewFileDate>
|
<dNewFileDate> optionally specifies the New File Date for the existing (File) Entry in the form of a valid Xbase++ Date value. The default value is the original File Date of the existing (File) Entry.
|
<cNewFileTime>
|
<cNewFileTime> optionally specifies the New File Time for the existing (File) Entry as a string in the following format: "HH:MM:SS". The default value is the original File Time of the existing (File) Entry.
|
This method returns the previous, old, File Date and File Time as an Array with two values. If the (File) Entry could not be found, the returned value is an array with two empty items: {NIL, NIL} or Array(2).
|
This method changes the File Date and Time (Stamp) of an existing (File) Entry in the Zip File to a new value, and returns the previous, old, File Date and Time (Stamp) of the Entry. If no Date is specified, the existing Date is not changed, and if no Time is specified, the existing Time is not changed. Therefore, if only one of the two values should be changed, the other value does not need to be specified and can be simply omitted!
|
|
The specified Date and Time value should be given as a Local Date/Time, as the given Date and Time will be converted to UTC (Universal Time), which will account for Time Zones and possibly active Daylight Savings Time settings. When the (File) Entry is extracted, the UTC Date/Time value is again converted to the Local Date/Time, which could result in the File receiving a different Date/Time than originally specified, if a different Time Zone (or Daylight Savings Time setting) is active.
|
|
It is possible to change the Date/Time Stamp of Directory Entries, but if a Directory is created by either the :Extract() or :ExtractAll() method, it will always show its actual Creation-Date and -Time and not the Date/Time Stamp of the Directory Entry from the Zip File!
|
Open an existing Zip File named "MyArchive.zip" and read its directory into an array. Then change the File Date of each (File) Entry of that Zip File to the current Date, but keep each Entry's original File Time. Then save the changes and close the Zip File:
|
|
oZip := XbZLibZip():New('MyArchive.zip')
|
aDir := oZip:Directory()
|
AEval(aDir, {|oR| oZip:ChangeFileDateTime(oR, Date())}
|
oZip:Close()
|