AddPackDirectory question

Just starting out? Need help? Post your questions and find answers here.
RSrole
User
User
Posts: 72
Joined: Fri Apr 29, 2022 8:27 pm

AddPackDirectory question

Post 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
RSrole
User
User
Posts: 72
Joined: Fri Apr 29, 2022 8:27 pm

Re: AddPackDirectory question

Post 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.
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: AddPackDirectory question

Post 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 "\"
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
RSrole
User
User
Posts: 72
Joined: Fri Apr 29, 2022 8:27 pm

Re: AddPackDirectory question

Post by RSrole »

Yes, you are right. It doesn't like the drive letter part of things.

Thanks
Post Reply