Hi,
everytime when there are some bank holidays I try to code a little bit. So sorry for my stupid question here,but I'm not doing that every day.
I want to convert an old program from PB 5.0 to PB 5.11 but the JCALG1 support is only for "unpacking".
Well, that would be okay, but it seems that I can use only the UncompressMemory-comamnd and not the Openpack-command.
This is too much for my coding skills. Can someone give me a code to open an old pack (JCALG1) archive and save the files directly or save the files in one of the new types (zip, whatever)?
Cheers
UseJCALG1Packer() - UncompressMemory to zip converter??
Re: UseJCALG1Packer() - UncompressMemory to zip converter??
Hi, before i've used freak's code, try if it can help you (using packed 'TweakUI.exe' inside DataSection):
Code: Select all
; freak: http://www.purebasic.fr/english/viewtopic.php?p=71438#71438
DataSection
FileStart:
IncludeBinary "output.pak"
FileEnd:
EndDataSection
UseJCALG1Packer()
Procedure.l UnpackIncludeFile(*CompressedData)
Static *UncompressedData
If *UncompressedData ; Free the memory from the last call (if there was any)
FreeMemory(*UncompressedData)
EndIf
OriginalSize = PeekL(*CompressedData) ; read the original size
*CompressedData + 4 ; move away from the size value to the packed data
*UncompressedData = AllocateMemory(OriginalSize) ; allocate enough memory
If *UncompressedData
If UncompressMemory(*CompressedData, OriginalSize, *UncompressedData, OriginalSize) ; uncompress the data and return the address
ProcedureReturn *UncompressedData
EndIf
EndIf
ProcedureReturn 0
EndProcedure
Procedure ExtractIncludePack(file_name.s)
Protected Unpack, Size
If CreateFile(0, file_name)
Unpack = UnpackIncludeFile(?FileStart)
Size = MemorySize(Unpack)
WriteData(0, Unpack, Size)
CloseFile(0)
ProcedureReturn 1
Else
MessageRequester("Error", "Could not install the file - Installation failed")
ProcedureReturn 0
EndIf
EndProcedure
ExtractIncludePack("TweakUI.exe")
