Page 1 of 1

AddPackDirectory question

Posted: Sun Jun 02, 2024 9:22 pm
by RSrole
I can call AddPackDirectory to add an empty directory, but I don't understand how to add files to that packed directory.

Any thoughts?

TIA,
Russ

Re: AddPackDirectory question

Posted: Sun Jun 02, 2024 10:50 pm
by RSrole
Ok, I fiddled around with it and figured it out.
Let's say you want to add a directory and then one file:
NewPack = CreatePack(#PB_Any,filename$,#PB_PackerPlugin_Zip) ; or whatever plugin you want to use
AddPackDirectory(NewPack,"PureBasic Projects") ; or whatever folder name you want
If you want to add a sub folder then:
AddPackDirectory(NewPack,"PureBasic Projects/MiscRoutines") ; so you have to build up the folder tree one by one
then
AddPackFile(NewPack,"c:\PureBasic Projects\MiscRoutines\MyRoutine.pb","PureBasic Projects/MiscRoutines/MyRoutine.pb")

It seems that the packer doesn't like the full path, meaning the drive letter x:\ and it also wants '/' instead of '\' for the packed name/path. Probably a unix thing. Perhaps someone more knowledgeable in this area can elaborate.

Re: AddPackDirectory question

Posted: Sun Jun 02, 2024 11:21 pm
by boddhi
RSrole wrote: It seems that the packer doesn't like the full path, meaning the drive letter x:\ and it also wants '/' instead of '\' for the packed name/path. Probably a unix thing. Perhaps someone more knowledgeable in this area can elaborate.

Code: Select all

UseZipPacker()
zipfile.s=GetTemporaryDirectory()+"temp.zip"
SourceDir.s=#PB_Compiler_Home+"Examples\Sources\Data\"

zp = CreatePack(#PB_Any, zipfile)
If zp
  AddPackFile(zp,SourceDir+"AlphaChannel.bmp","AlphaChannel.bmp") ; Root
  AddPackFile(zp,SourceDir+"Background.bmp","Temp\Background.bmp") ; Unexisting path 
  AddPackDirectory(zp,"Temp\Temp")
  AddPackFile(zp,#PB_Compiler_Home+"Examples\Sources\Data\PureBasic.bmp","Temp\Temp\PureBasic.bmp") ; Just created path
  ClosePack(zp)
EndIf
Works fine with "\"

Re: AddPackDirectory question

Posted: Sun Jun 02, 2024 11:56 pm
by RSrole
Yes, you are right. It doesn't like the drive letter part of things.

Thanks