Page 1 of 1

AddPackEmptyDirs Crossplattform without API

Posted: Tue Feb 12, 2013 9:35 pm
by ts-soft
The new PackerLibs supports directories for PackEntryType but there is no native function to add empty directories.
Here is a workaround for ZipPacker without using external lib!

Code: Select all

UseZipPacker()

Procedure AddPackEmptyDirs(ID, name.s)
  If name <> ""
    ReplaceString(name, "\", "/", #PB_String_InPlace)
    If Right(name, 1) <> "/" : name + "/" : EndIf
    ProcedureReturn AddPackMemory(ID, 0, 0, name)
  EndIf
EndProcedure

CreatePack(0, GetTemporaryDirectory() + "test.zip")
AddPackEmptyDirs(0, "test")
AddPackEmptyDirs(0, "bla\blub\PB\")
ClosePack(0)

If OpenPack(0, GetTemporaryDirectory() + "test.zip")
  If ExaminePack(0)
    While NextPackEntry(0)
      Debug PackEntryName(0)
      Debug PackEntryType(0)
      Debug "---------------"
    Wend
  EndIf
  ClosePack(0)
EndIf
Is not the biggest Code :mrgreen: , but i think this can be usefull :wink:

Have Fun

Re: AddPackEmptyDirs Crossplattform without API

Posted: Wed Feb 13, 2013 9:09 am
by jamirokwai
Hi TS-Soft,

nice, so easy!
Should be made a native command in PB :-)

Re: AddPackEmptyDirs Crossplattform without API

Posted: Wed Feb 13, 2013 9:16 am
by Kwai chang caine
Very useful, there are a long time i had this problem with the native pack (Not ZIP)
Thanks for sharing 8)