Code: Select all
; Code tested with:
; PB 6.30 beta 2 (x64) on Windows 11
EnableExplicit
UseZipPacker()
#Mask$ = "%yyyy-%mm-%dd"
Global g_TempPath$ = GetTemporaryDirectory() + "PureBasicTemp/"
Procedure.i Unpack (archive$)
Protected.i ifn, count=0, ret=0
Protected pkCreated$, pkAccessed$, pkModified$
Protected created$, accessed$, modified$
ifn = OpenPack(#PB_Any, archive$)
If ifn = 0
ProcedureReturn 1 ; error
EndIf
If FileSize(g_TempPath$) <> -2 And CreateDirectory(g_TempPath$) = 0
ClosePack(ifn)
ProcedureReturn 2 ; error
EndIf
If ExaminePack(ifn)
Debug "Files in archive '" + archive$ + "'"
Debug ""
Debug Space(46) + "PACKED" + Space(19) + "|" + Space(15) + "UNPACKED"
Debug LSet("Name", 30) + " Created Accessed Modified | Created Accessed Modified"
Debug "----------------------------- ---------- ---------- ---------- | ---------- ---------- ----------"
While NextPackEntry(ifn)
If PackEntryType(ifn) = #PB_Packer_File
count + 1
If UncompressPackFile(ifn, g_TempPath$ + PackEntryName(ifn)) = -1
Debug "Error: unsuccessful unpacking of file: " + PackEntryName(ifn)
ret = 3 ; error
Else
pkCreated$ = RSet(FormatDate(#Mask$, PackEntryDate(ifn, #PB_Date_Created)), 13)
pkAccessed$ = RSet(FormatDate(#Mask$, PackEntryDate(ifn, #PB_Date_Accessed)), 13)
pkModified$ = RSet(FormatDate(#Mask$, PackEntryDate(ifn, #PB_Date_Modified)), 13)
created$ = RSet(FormatDate(#Mask$, GetFileDate(g_TempPath$ + PackEntryName(ifn), #PB_Date_Created)), 12)
accessed$ = RSet(FormatDate(#Mask$, GetFileDate(g_TempPath$ + PackEntryName(ifn), #PB_Date_Accessed)), 13)
modified$ = RSet(FormatDate(#Mask$, GetFileDate(g_TempPath$ + PackEntryName(ifn), #PB_Date_Modified)), 13)
Debug LSet(PackEntryName(ifn), 30) +
pkCreated$ + pkAccessed$ + pkModified$ + " |" +
created$ + accessed$ + modified$
EndIf
If count = 10 ; TODO: Set this to 0 to show all entries.
Debug "[...]"
Break
EndIf
EndIf
Wend
Debug ""
EndIf
ClosePack(ifn)
ProcedureReturn ret
EndProcedure
Debug Unpack("C:\Program Files\PureBasic\Themes\SilkTheme.zip")
; Program version in this directory:
; PB 6.30 beta 2 (x64) on Windows 11
Output:
Code: Select all
Files in archive 'C:\Program Files\PureBasic\Themes\SilkTheme.zip'
PACKED | UNPACKED
Name Created Accessed Modified | Created Accessed Modified
----------------------------- ---------- ---------- ---------- | ---------- ---------- ----------
accept.png 2025-09-12 2020-09-28 | 2025-09-15 2025-09-16 2025-09-16
add.png 2025-09-12 2020-09-28 | 2025-09-15 2025-09-16 2025-09-16
application_add.png 2025-09-12 2020-09-28 | 2025-09-15 2025-09-16 2025-09-16
application_form.png 2025-09-12 2020-09-28 | 2025-09-15 2025-09-16 2025-09-16
application_form_add.png 2025-09-12 2020-09-28 | 2025-09-15 2025-09-16 2025-09-16
application_home.png 2025-09-12 2020-09-28 | 2025-09-15 2025-09-16 2025-09-16
application_tile_vertical.png 2025-09-12 2020-09-28 | 2025-09-15 2025-09-16 2025-09-16
application_view_columns.png 2025-09-12 2020-09-28 | 2025-09-15 2025-09-16 2025-09-16
application_view_gallery.png 2025-09-12 2020-09-28 | 2025-09-15 2025-09-16 2025-09-16
application_view_tile.png 2025-09-12 2020-09-28 | 2025-09-15 2025-09-16 2025-09-16
[...]
0
This should not happen IMHO. Other professional programs that unpack archives on Windows (e.g. Total Commander) preserve the modification dates of packed files after unpacking them. Also PureBasic's CopyFile() and RenameFile() don't touch the modification dates of files. So for consistency and according to the principle of least surprise, UncompressPackFile() also shouldn't touch the modification date of the files.
PS: I know that we can use something like
Code: Select all
SetFileDate(g_TempPath$ + PackEntryName(ifn), #PB_Date_Modified, PackEntryDate(ifn))