UncompressPackFile()
Syntax
Result = UncompressPackFile(#Pack, Filename$ [, PackedFilename$])Description
Uncompress into the specified filename from the current pack entry being examined with ExaminePack() and NextPackEntry(). If the filename already exists, it will erased and replaced with the new uncompressed data.
Parameters
#Pack The pack to use. Filename$ The filename to uncompress the current pack entry. PackedFilename$ (optional) The packed filename entry to uncompress. If this parameter is not specified, the current entry being examined with ExaminePack() and NextPackEntry() is uncompressed.
Return value
Return the uncompressed size if the pack entry has been successfully uncompressed into the filename, -1 otherwise.
Example
UseZipPacker() Path$ = "C:/ProgramData/PureBasic/Examples/Sources/Data/" ; path to the PureBasic examples data/media files PackFile$ = "C:/ProgramData/PureBasic/Examples/MyCompressedFiles.zip" ; path to the pack file which should be created and opened later If CreatePack(0, PackFile$) AddPackFile(0, Path$ + "world.png", "world.png") AddPackFile(0, Path$ + "test.pref", "test.pref") AddPackFile(0, Path$ + "CdPlayer.ico", "CdPlayer.ico") AddPackFile(0, Path$ + "Background.bmp", "Background.bmp") ClosePack(0) Debug "PackFile successfully created: " + PackFile$ Else Debug "Error creating the pack file!" EndIf Path$ = "C:/ProgramData/PureBasic/Examples/test_delete/" ; path to a directory into which the pack files should be extracted If OpenPack(0, PackFile$) If CreateDirectory(Path$) Or FileSize(Path$) = -2 If ExaminePack(0) Debug "Archive contents to be unpacked:" While NextPackEntry(0) Debug " - name: " + PackEntryName(0) + ", size: " + PackEntrySize(0) If UncompressPackFile(0, Path$ + PackEntryName(0), PackEntryName(0)) = -1 Debug "Error: unsuccessful unpacking of file: " + PackEntryName(0) EndIf Wend EndIf ClosePack(0) RunProgram(Path$) ; open the directory with the unpacked files Else Debug "Error while creating the folder to unpack the archive contents!" EndIf Else Debug "Error opening the pack file!" EndIfFor another example see AddPackFile().
See Also
OpenPack(), ExaminePack(), NextPackEntry()
Supported OS
All