Suggestions for the Packer library
Posted: Fri Mar 10, 2006 10:32 am
These both new functions would be usefull:
- CountPackFile(packfile.s) : return the number of elements of the pack file
- GetPackFile(packfile.s, index.l, target.s) : extract the x element and save it to the specified file
Something like this:
and also an AppendPackFile function to add files at the end of the packer file that already exists.
- CountPackFile(packfile.s) : return the number of elements of the pack file
- GetPackFile(packfile.s, index.l, target.s) : extract the x element and save it to the specified file
Something like this:

Code: Select all
Procedure.l CountPackFile(file.s)
Protected cpt.l = 0
If OpenPack(file)
While NextPackFile()
cpt + 1
Wend
ClosePack()
EndIf
ProcedureReturn cpt
EndProcedure
Procedure.l GetPackFile(src_file.s, index.l, trg_file.s)
Protected i.l, *mem.l, fic.l, size.l
size = 0
If (index > 0) And (index <= CountPackFile(src_file))
If OpenPack(src_file)
For i = 1 To index
*mem = NextPackFile()
Next i
size = PackFileSize()
fic = CreateFile(#PB_Any, trg_file)
If fic
WriteData(fic, *mem, size)
CloseFile(fic)
EndIf
ClosePack()
EndIf
EndIf
ProcedureReturn size
EndProcedure