The ABC Programmer (voxel@freenet.edmonton.ab.ca) ZIP VIEWER FOR PB ------------------------------------------------------------------------------ '----------------------------[ ZIP Viewer ]------------------------------- ' No frills .ZIP Viewer for PB by William Yu (12-03-97) Public Domain. ' With help from: Steve Wierenga (his Pascal code to be precise). ' ' If you're wondering how I got the Date/Time thing to work, check this: ' ' bits field It's just one long 32-bit number ' ---- ----- Pretty cool for only 4 bytes worth. ' 0-5 = seconds ' 6-11 = minutes ' 12-16 = hours ' 17-21 = days ' 22-25 = months ' 26-31 = years ' '------------------------------------------------------------------------- DEFINT A-Z %SIG = &H04034B50 ' Signature TYPE ZFHeader ' Zip File Header Signature as Long Version as word GPBFlag as word ' Not sure Compress as word ' Compression type DateTime as Long ' Took a while to figure out CRC32 as Long CSize as Long USize as Long FileNameLen as Long ExtraField as Word ' Not sure END TYPE DIM CompTypes(0 to 9) AS SHARED String*9 FOR I=0 to 9 READ CompTypes(I) NEXT I DATA Stored,Shrunk,Reduced1,Reduced2,Reduced3 DATA Reduced4,Imploded,Deflated,DeflatN,DeflatX CLS ?".ZIP Viewer (Public Domain) by William Yu, with help from Steve Wierenga":? ZipView COMMAND$ END SUB ZipView(ZIPFile AS String) ' View the ZIP File DIM totalu as Long DIM totalc as Long DIM totalf as Word DIM Hdr as ZFHeader DIM F as String DIM Year AS LONG DIM Month AS LONG DIM Day AS LONG DIM Hour AS WORD ' We don't need the upper 2 bytes anymore. DIM Minute AS WORD ' Works both ways. DIM Secs AS WORD IF ZIPFile="" THEN ?"Usage: ZIPVIEW [Path:\]filename.ZIP EXIT SUB END IF ' Init Variables totalu = 0: totalc = 0: totalf = 0 ZIP = FREEFILE OPEN ZIPFile FOR BINARY AS ZIP IF LOF(ZIP)=0 THEN ' Check if files exists ?ZipFile;" does not exist!" ' if not, exit CLOSE ZIP KILL ZipFile EXIT SUB END IF ? "Searching: ";ZIPFile:? ? USING "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \";_ "FileName";" Length";" Size";"Rate";" Date";" Time";" Method";" CRC-32" ? USING "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \";_ "------------";"--------";"-------";"----";"--------";"--------";"--------";"--------" DO GET ZIP,,Hdr ' Read File Header IF (Hdr.Signature = %Sig) Then ' Is a header F=SPACE$(Hdr.FileNameLen) ' Grab filename GET ZIP,LOC(ZIP)-2,F Year=Hdr.DateTime:Shift Right Year, 25:Year=Year AND &H7F Month=Hdr.DateTime:Shift Right Month, 21:Month=Month AND &H0F Day=Hdr.DateTime:Shift Right Day, 16: Day=Day AND &H1F Hour=Hdr.DateTime:Shift Right Hour, 11: Hour=Hour AND &H1F Minute=Hdr.DateTime:Shift Right Minute, 5:Minute=Minute AND &H3F Secs=Hdr.DateTime AND &H1F M$=LTRIM$(STR$(Month)) D$=LTRIM$(STR$(Day)) IF LEN(M$)=1 THEN M$="0"+M$ IF LEN(D$)=1 THEN D$="0"+D$ A$=M$+"-"+D$+"-"+LTRIM$(STR$(Year+80)) ' Year starts at 1980 H$=LTRIM$(STR$(Hour)) M$=LTRIM$(STR$(Minute)) S$=LTRIM$(STR$(Secs)) IF LEN(H$)=1 THEN H$="0"+H$ IF LEN(M$)=1 THEN M$="0"+M$ IF LEN(S$)=1 THEN S$="0"+S$ B$=H$+":"+M$+":"+S$ ? USING "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \";F;STR$(Hdr.USize);_ STR$(Hdr.CSize);STR$(INT(100-Hdr.CSize/Hdr.USize*100))+"%";A$;B$;_ CompTypes(Hdr.Compress);lcase$(HEX$(Hdr.CRC32)) Incr TotalU,Hdr.USize ' Increment size uncompressed Incr TotalC,Hdr.CSize ' Increment size compressed Incr TotalF END IF SEEK ZIP,LOC(ZIP)+Hdr.CSize '+Hdr.ExtraField LOOP Until Hdr.Signature <> %SIG ' No more Files ?STRING$(72,"-") ? USING "\ \ \ \ \ \ \ \ \ \ \ \";_ STR$(TotalF);STR$(TotalU);STR$(TotalC);STR$(INT(100-TotalC/TotalU*100))+"%"; CLOSE ZIP END SUB