Page 2 of 2

Posted: Sat Jul 26, 2008 12:26 pm
by Little John
PB wrote:The Goto thing was a joke. :) But since there was a reaction, how could the
code be modified NOT to use it, since so many people say that any code can
be written without Goto if they really wanted to. To those people: show me.
Just look at the original VB code. There is no Goto at all. ;-)

Regards, Little John

Posted: Sun Oct 05, 2008 7:36 am
by PB
Can this be modified to parse a cab file? I heard cabs are just zips?

Posted: Mon Oct 06, 2008 2:13 pm
by gnozal
PB wrote:I heard cabs are just zips?
Imho M$ cabinet files (CAB) are not just zip files, neither are Installshield archives (also CAB).

Re:

Posted: Mon Jun 08, 2015 2:20 am
by Dude
Does someone know how to convert srod's example to Unicode? It currently lists all zip names in Asian characters on my English PC.

Re: Parse zip file without using a library

Posted: Mon Jun 08, 2015 4:32 am
by JHPJHP
Hi Dude,

It works if the Unicode switch is unchecked from the Menu -- Compiler Options, or...

Here is a version that works with or without the Unicode option checked:

Code: Select all

Structure typZipLocalFileHead
  zlfhSignature.l
  zlfhVersion.w
  zlfhBitFlag.w
  zlfhCompression.w
  zlfhModFileTime.w
  zlfhModFileData.w
  zlfhCRC.l
  zlfhCompressedSize.l
  zlfhUncompressedSize.l
  zlfhFileNameLength.w
  zlfhExtraFieldLength.w
EndStructure

Procedure ListZipFile(Filename.s)
  ReadHead.typZipLocalFileHead
  FF = ReadFile(#PB_Any, Filename)

  If FF
    Repeat
      ReadHead\zlfhSignature = ReadLong(ff)

      If ReadHead\zlfhSignature = $4034B50
        FileSeek(FF, Loc(ff) - 4)
        ReadData(FF, @ReadHead, SizeOf(ReadHead))
  
        With ReadHead
          If \zlfhFileNameLength <> 0
            *FileString = AllocateMemory(\zlfhFileNameLength)
            ReadData(FF, *FileString, \zlfhFileNameLength)
            Debug PeekS(*Filestring, \zlfhFileNameLength, #PB_Ascii)
            FreeMemory(*FileString)
          EndIf
          Debug"  Compressed = "  + Str(\zlfhCompressedSize) + " UnCompressed = "  + Str(\zlfhUnCompressedSize)
          SeekSize = \zlfhCompressedSize

          If \zlfhExtraFieldLength : SeekSize + \zlfhExtraFieldLength : EndIf
          If (\zlfhBitFlag & $4) : SeekSize + 12 : EndIf

        EndWith
        Seeksize + Loc(FF)
        FileSeek(FF, Seeksize)
        Filecount + 1
      Else
        If fileCount = 0 : Debug "No valid ZIP" : EndIf

        quitLoop = 1
      EndIf
    Until quitLoop
    Debug Str(Filecount) + " in ZipFile"
    CloseFile(FF)
  EndIf
EndProcedure

FileName.s = OpenFileRequester("Please choose a ZIP file to load", "", "ZIP File (*.zip)|*.zip|All files (*.*)|*.*", 0)

If SizeOf(FileName) > 0 : ListZipFile(FileName) : EndIf

Re: Parse zip file without using a library

Posted: Mon Jun 08, 2015 4:49 am
by Dude
Thanks JHPJHP, I needed this because my app is Unicode. :)

Re: Parse zip file without using a library

Posted: Wed Jun 10, 2015 1:00 pm
by holzhacker
Dear,

In "Linux Ubuntu 14.04 LTS - Gnome 3.0" does not recover the file names, other information this recovering Ok.

In time, clearing the unicode compiler option it works as expected on Linux.