Packer lib path seperator error in AddPackFile

Just starting out? Need help? Post your questions and find answers here.
Wolfgang2
User
User
Posts: 11
Joined: Wed Jan 31, 2018 4:03 pm

Packer lib path seperator error in AddPackFile

Post 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
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Packer lib path seperator error in AddPackFile

Post by ts-soft »

Not a bug. Use always slash and not backslash, on all OS!
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Fred
Administrator
Administrator
Posts: 16687
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Packer lib path seperator error in AddPackFile

Post by Fred »

zip is a cross plateform archive format, so path are automatically changed by the zip lib (we don't change them ourself).
BarryG
Addict
Addict
Posts: 3330
Joined: Thu Apr 18, 2019 8:17 am

Re: Packer lib path seperator error in AddPackFile

Post 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.
Post Reply