Share your advanced PureBasic knowledge/code with the community.
Little John
Addict
Posts: 4791 Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany
Post
by Little John » Sat Jul 26, 2008 12:26 pm
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
PB
PureBasic Expert
Posts: 7581 Joined: Fri Apr 25, 2003 5:24 pm
Post
by PB » Sun Oct 05, 2008 7:36 am
Can this be modified to parse a cab file? I heard cabs are just zips?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
gnozal
PureBasic Expert
Posts: 4229 Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:
Post
by gnozal » Mon Oct 06, 2008 2:13 pm
PB wrote: I heard cabs are just zips?
Imho M$ cabinet files (CAB) are not just zip files, neither are Installshield archives (also CAB).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Dude
Addict
Posts: 1907 Joined: Mon Feb 16, 2015 2:49 pm
Post
by Dude » Mon Jun 08, 2015 2:20 am
Does someone know how to convert srod's example to Unicode? It currently lists all zip names in Asian characters on my English PC.
JHPJHP
Addict
Posts: 2258 Joined: Sat Oct 09, 2010 3:47 am
Post
by JHPJHP » Mon Jun 08, 2015 4:32 am
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
Dude
Addict
Posts: 1907 Joined: Mon Feb 16, 2015 2:49 pm
Post
by Dude » Mon Jun 08, 2015 4:49 am
Thanks JHPJHP, I needed this because my app is Unicode.
holzhacker
Enthusiast
Posts: 125 Joined: Mon Mar 08, 2010 9:14 pm
Location: "Mens sana in corpore sano"
Contact:
Post
by holzhacker » Wed Jun 10, 2015 1:00 pm
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.