02-08-2024, 01:33 PM
Here my version of the program making list of files into a ZIP(with name, sizes, date, hour)
(compatible QB64 & QB64pe, Win)
(compatible QB64 & QB64pe, Win)
Code: (Select All)
'See useful informations about ZIP header --> 'https://medium.com/@felixstridsberg/the-zip-file-format-6c8a160d1c34
'This version by Euklides
'Objet: create a list of files placed into a zip file (name, compressed and normal sizes, date , time)
'Works with .ZIP files, .EPUB files & .CBZ files
'---put your ZIP file here---
fi$ = "D:\temp\essai.zip"
'-------------------------
Close #1: Open fi$ For Binary As #1: txe$ = Space$(LOF(1)): Get #1, , txe$: Close #1
Amorce$ = "PK" + Chr$(3) + Chr$(4): jj = 1: jj = InStr(jj, txe$, Amorce$) + 2: NBFILE = 0
Refait: jk = InStr(jj, txe$, Amorce$): jj = jk + 1
If jk = 0 Then GoTo Fino
'---------sizes (compress, normal) name of the included files
Bloc$ = Mid$(txe$, jk + 18, 4): GoSub Converti: XVolCompress = AV#
Bloc$ = Mid$(txe$, jk + 22, 4): GoSub Converti: XVolNormal = AV#
Bloc$ = Mid$(txe$, jk + 25, 2): largeur = Asc(Mid$(Bloc$, 1, 1)) * 256 + Asc(Mid$(Bloc$, 2, 1))
XName$ = Mid$(txe$, jk + 30, largeur): NBFILE = NBFILE + 1
'---------Date of file
Zonedate$ = Mid$(txe$, jk + 12, 2): OCTETDATE$ = "":
QQ = Asc(Mid$(Zonedate$, 2, 1)): GoSub OCTETBIT: OCTETDATE$ = oc$
QQ = Asc(Mid$(Zonedate$, 1, 1)): GoSub OCTETBIT: OCTETDATE$ = OCTETDATE$ + oc$
oc$ = Right$(OCTETDATE$, 5): GoSub BITOCTET: XDAY = QQ:
oc$ = Mid$(OCTETDATE$, 8, 4): GoSub BITOCTET: XMONTH = QQ
oc$ = Left$(OCTETDATE$, 7): GoSub BITOCTET: XYEAR = QQ + 1980
'---------time of the file
Zoneheure$ = Mid$(txe$, jk + 10, 2): OCTETDATE$ = ""
QQ = Asc(Mid$(Zoneheure$, 2, 1)): GoSub OCTETBIT: OCTETDATE$ = oc$
QQ = Asc(Mid$(Zoneheure$, 1, 1)): GoSub OCTETBIT: OCTETDATE$ = OCTETDATE$ + oc$
oc$ = Right$(OCTETDATE$, 5): GoSub BITOCTET: XHOUR = QQ
oc$ = Mid$(OCTETDATE$, 6, 6): GoSub BITOCTET: XMINU = QQ
oc$ = Left$(OCTETDATE$, 5): GoSub BITOCTET: XSEC = QQ * 2
'---------using informations here (example)
' File Name |chr$(124) Size compressed chr$(124) Normal size
T$ = XName$ + "|" + _Trim$(Str$(XVolCompress)) + "|" + _Trim$(Str$(XVolNormal))
'date YYYY~MM~DD
XDATE$ = Right$(Str$(XYEAR + 10000), 4) + "~" + Right$(Str$(100 + XMONTH), 2) + "~" + Right$(Str$(100 + XDAY), 2)
T$ = T$ + "|" + XDATE$
'TIME: hh:mm:ss Not very significant because it depends on the place of creation of the ZI ¨P
XTIME$ = Right$(Str$(XHOUR + 100), 2) + ":" + Right$(Str$(XMINU + 100), 2) + ":" + Right$(Str$(XSEC + 100), 2)
T$ = T$ + "|" + XTIME$
Print T$: 'input kk$
'---next file
GoTo Refait
'---end
Fino:
Print fi$
Print "Number of files: "; NBFILE
End
Converti: '-------------in bloc$ with 1,2,3 or 4 bytes to convert to numerical value
If Len(Bloc$) < 3 Then Bloc$ = Left$(Bloc$ + Chr$(0) + Chr$(0) + Chr$(0), 4)
A1 = Asc(Mid$(Bloc$, 1, 1)): A2 = Asc(Mid$(Bloc$, 2, 1)): A3 = Asc(Mid$(Bloc$, 3, 1)): A4 = Asc(Mid$(Bloc$, 4, 1))
AV# = A0 + (A2 * 256) + (A3 * 256 * 256) + (A4 * 256 * 256 * 256)
Return
OCTETBIT: '------------- in QQ out oc$
oc$ = ""
Bito: QQ = QQ / 2: If QQ <> Int(QQ) Then oc$ = "1" + oc$ Else oc$ = "0" + oc$
If Int(QQ) > 0 Then QQ = Int(QQ): GoTo Bito
oc$ = Right$("000000000" + oc$, 8): Return
BITOCTET: '------------- bin oc$ out QQ
DECAoc: If Left$(oc$ + "x", 1) = "0" Then oc$ = Right$(oc$, Len(oc$) - 1): GoTo DECAoc
If oc$ = "" Then QQ = 0: Return
QQ = Val(Left$(oc$, 1))
For xo = 2 To Len(oc$): If Mid$(oc$, xo, 1) = "0" Then QQ = QQ * 2 Else QQ = (QQ * 2) + 1
Next xo: Return
Why not yes ?