PureCAB library
Overview
This is a purebasic 4.6x user library.Functions
PureCAB_Create(Archive.s)Create a new CAB archive.PureCAB_Compress(Handle.l, Filename.s [, NameInArchive.s])
Returned values :
- Archive handle [if success]
- #False [if failed]
Note :
If the file already existed, it will be deleted!
Add a file to an archive.PureCAB_Close(Handle.l)
Arguments :
- Handle : archive handle [returned by PureCAB_Create()]
- Filename : file to add to the archive
- NameInArchive : name in the archive [optional]
Returned value :
- #True : if success
- #False : if failed
Note :
A compression callback can be set with PureCAB_SetCompressionCallback().
Closes an archive opened with PureCAB_Create().PureCAB_FindFirst(Archive.s)
Find first file in archive.PureCAB_FindNext()
Returned values :
- #True : at least one file in the archive
- #False : no file found
Find next file in archive.PureCAB_GetInfo(*FileInfo.PureCAB_FileInfo)
Returned values :
- #True : found next file in archive
- #False : end of archive
Get archived file information.PureCAB_ExtractFile(Archive.s, Filename.s, OutputPath.s)
Returned values :
Structure PureCAB_FileInfo
NameInCabinet.s ; archived filename
FileSize.q ; archived filesize
EndStructure
Extract file from archive.PureCAB_ExtractAll(Archive.s, OutputPath.s)
Returned value :
- Number of files processed
Extract all files from archive.PureCAB_SetCompressionCallback(*CompressionCallback)
Returned value :
- Number of files processed
Set a compression callback.PureCAB_SetExtractionCallback(*ExtractionCallback)
The callback is called in realtime during compression.
Useful to indicate the progress when a big file is packed.
CompilerIf #PB_Compiler_Unicode
Procedure.l MyCustom_Compression_StatusCallBack(*Filename, PerCent.f)
Debug "Packing " + PeekS(*Filename, #PB_Any, #PB_Ascii) + " - " + StrF(PerCent, 2) + "%"
EndProcedure
CompilerElse
Procedure.l MyCustom_Compression_StatusCallBack(Filename.s, PerCent.f)
Debug "Packing " + Filename + " - " + StrF(PerCent, 2) + "%"
EndProcedure
CompilerEndIf
Set an extraction callback.
The callback is called during decompression.
Useful to indicate some progress when a big archive is unpacked.
Procedure MyCustom_Extraction_StatusCallBack(Filename.s, Status.l)
Select Status
Case 0 ; Extraction begins
Debug "Extracting ... " + Filename
Case 1 ; Extraction ends
Debug "Extracted --> " + Filename
EndSelect
EndProcedure
Note :
Fine progression data (like a PerCent.f parameter) is not available.