PureLZMA-Packer library
Overview
This PB4.3x user library adds archiver functions to PureLZMA.
Note : the PureLZMA library is required !
Functions
PureLZMA_Archive_Create(Archive.s)PureLZMA_Archive_CreateSFX(SFXStub.s)Create a new archive. If the file already existed, it will be erased. Returned value : - #Null if failed - else : successPureLZMA_Archive_Update(Archive.s)Create a new SFX archive. If the file already existed, it will be erased. SFXStub is the path to the SFX stub, i.e. selfextracting module. The stub may use the function PureLZMA_Archive_ReadSFX(ProgramFilename()) to open the appended archived data. This is useful to create selfextracting archives (SFX) or installers. Returned value : - #Null if failed - else : successPureLZMA_Archive_UpdateSFX(Archive.s)Opens an existing archive for update. Returned value : - #Null if failed - else : successPureLZMA_Archive_Read(Archive.s)Opens an existing selfextracting archive (SFX) for update. Returned value : - #Null if failed - else : successPureLZMA_Archive_ReadSFX(Archive.s)Opens an existing archive for reading. Returned value : - #Null if failed - else : successPureLZMA_Archive_Close()Opens an existing selfextracting archive (SFX) for reading. Returned value : - #Null if failed - else : successPureLZMA_Archive_Compress(FileName.s, KeepPath.l [, EncryptionKey.s])Close the current archive. If any records were marked for deletion, they are deleted now. Returned value : - #Null if requested record deletion failed - else : successPureLZMA_Archive_CompressMem(*MemoryBuffer, MemoryBufferLen.l, FileName.s [, EncryptionKey.s])Add a file to the current archive. Parameters : Filename : File to compress KeepPath : 0 -> path is not stored : 1 -> path is stored : -1 -> no file name is stored [empty string] EncryptionKey : Optional RC4 encryption key Returned values : Success : 1 : File compressed (and crypted if applicable) 2 : File stored (and crypted if applicable) Failure : -1 : Memory allocation error (not enough memory available ?) -2 : File access error -3 : Compression errorPureLZMA_Archive_AddFiles(FileMask.s, Recursive.l, StorePath.l [, EncryptionKey.s [, *ProgressionCallback]])Add a memory buffer to the current archive. Parameters : *MemoryBuffer : Memory buffer to compress MemoryBufferLen : Memory buffer length Filename : Filename to label the memory buffer [might be ""] EncryptionKey : Optional RC4 encryption key Returned values : Success : 1 : Buffer compressed (and crypted if applicable) 2 : Buffer stored (and crypted if applicable) Failure : -1 : Memory allocation error (not enough memory available ?) -2 : File access error -3 : Compression errorPureLZMA_Archive_Extract(FileName.s [, EncryptionKey.s])Add file(s) to the current archive. Parameters : Filemask : File(s) to compress Recursive : Recursive file search StorePath : #PureLZMA_DontStorePath -> path is not stored : #PureLZMA_StorePathAbsolute -> store path (absolute) : #PureLZMA_StorePathRelative -> store path relative to base directory EncryptionKey : Optional RC4 encryption key *ProgressionCallback : Optional progression callback address The progression callback may be useful to indicate some progress while packing a lot of files. Procedure.l MyProgressionCallback(FileName.s, PackStatus.l) ; PackStatus values : ; Info 0 : File 'FileName' will be added ; Status 1 : Compressed (and crypted if applicable) ; 2 : Stored (and crypted if applicable) ; -1 : Memory allocation error ; -2 : File access error ; -3 : Compression error ; Return #True to abort compression EndProcedure Returned values : >=0 : number of compressed files -1 : aborted (from callback)PureLZMA_Archive_ExtractMem(*MemoryBuffer, MemoryBufferLen.l [, EncryptionKey.s])Extract current record from archive Parameters : Filename : Extracted data filename EncryptionKey : Optional RC4 encryption key [if data was encrypted] Returned values : Success : : #True Failure : : 0 -> no current record : -1 -> memory allocation error : -2 -> file access error : -3 -> unpack errorPureLZMA_Archive_FindFirst()Extract current record from archive to memory buffer. Parameters : *MemoryBuffer : Destination memory buffer MemoryBufferLen : Destination memory buffer length EncryptionKey : Optional RC4 encryption key [if data was encrypted] Returned values : Success : : #True Failure : : 0 -> no current record : -1 -> memory allocation error : -2 -> file access error : -3 -> unpack errorPureLZMA_Archive_FindNext()Find the first record in the archive. To be used with PureLZMA_Archive_FindNext(). Returned value : - #True if success - #False if failedPureLZMA_Archive_DeleteRecord()Find the next record in the archive. To be used after PureLZMA_Archive_FindFirst(). Returned value : - #True if success - #False if failedPureLZMA_Archive_GetArchiveInfo(*ArchiveInfo.LZMA_ArchiveInfo)Delete the current archived record. Note : The current record is marked for deletion ; the deletion is delayed until the archive is closed Deletion is not supported for selfextracting archives. Returned value : - #True if success - #False if failedPureLZMA_Archive_GetCRC()Get archived record information. Parameter : *ArchiveInfo : pointer to a LZMA_ArchiveInfo structure. Structure LZMA_ArchiveInfo CRCUnpacked.l ; Unpacked data CRC32 CRCPacked.l ; Packed data CRC32 LengthUnpacked.l ; Unpacked data length LengthPacked.l ; Packed data length LZMAFlags.l ; LZMA Packer flags FileAttributes.l ; Packed file attributes Filename.s ; Filename for packed data EndStructure LZMAFlags : #LZMA_Flag_Stored = 0 -> data is stored #LZMA_Flag_Compressed = 1 -> data is compressed [LZMA] #LZMA_Flag_Crypted = 2 -> data is crypted [RC4] #LZMA_Flag_Deleted = 4 -> record is marked for deletion Returned value : - #True if success - #False if failedCalculate the CRC32 for current archived record. Useful to check record integrity.