Page 1 of 1

Packer lib path seperator error in AddPackFile

Posted: Wed Sep 11, 2019 1:21 pm
by Wolfgang2
If a file is added to a ZIP pack and the PackedFilename includes a path, like "test\myfile.txt", the filename later returned by PackEntryName() always contains a "/" as path seperator, not a "\" as required by windows.
I did so far only check ZIP format and Windows.
Purebasic Version 5.70LTS 64bit Windows

Code: Select all

; This demo shows a packer lib bug if run under MS windows7 professional SP1
; a file with a path name in the PackedFilename is added : test\PureBasic.chm
; this file IS indeed added in a subfolder "test" in the zip file.
; BUT if this pack is later examined with ExaminePack(), the PackEntryName() returns a "/" as path seperator, even if all operations are done under windows where the path seperator is "\"
;
UseZipPacker()
Debug "compiler home : " + #PB_Compiler_Home
 packer = CreatePack(#PB_Any,"c:\test.zip",#PB_PackerPlugin_Zip)
 If packer
   AddPackFile(packer,#PB_Compiler_Home+"PureBasic.chm","test\PureBasic.chm")
   ClosePack(packer)
 EndIf
 If OpenPack(0,"c:\test.zip",#PB_PackerPlugin_Zip)
   ExaminePack(0)
   While NextPackEntry(0)
     Debug "Name: " + PackEntryName(0) + ", Size: " + PackEntrySize(0) 
   Wend   
   ClosePack(0)
 EndIf

Re: Packer lib path seperator error in AddPackFile

Posted: Wed Sep 11, 2019 5:23 pm
by ts-soft
Not a bug. Use always slash and not backslash, on all OS!

Re: Packer lib path seperator error in AddPackFile

Posted: Tue Dec 17, 2019 4:03 pm
by Fred
zip is a cross plateform archive format, so path are automatically changed by the zip lib (we don't change them ourself).

Re: Packer lib path seperator error in AddPackFile

Posted: Fri Nov 12, 2021 1:35 pm
by BarryG
Wolfgang2 wrote: Wed Sep 11, 2019 1:21 pmthe filename later returned by PackEntryName() always contains a "/" as path seperator, not a "\" as required by windows
Confirmed for Windows. I used the Packer lib to open a zip file created by PeaZip, and the PackEntryName() names have "/" in them, meaning I couldn't use UncompressPackFile() to extract them - I had to search/replace each PackEntryName() and convert every "/" to "\" first.

Can the Packer lib be fixed/enhanced to change the path separator based on the OS being compiled? Thanks.