Help with Packer, please. - Zip signature

Just starting out? Need help? Post your questions and find answers here.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Help with Packer, please. - Zip signature

Post by davido »

When I write Zip files with the Packer they do not seem to have the usual Zip signature: PK as the first to bytes.

Am I doing something wrong or is there a way to add the two or four signature bytes?
DE AA EB
infratec
Always Here
Always Here
Posts: 6810
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Help with Packer, please. - Zip signature

Post by infratec »

Normally I don't test anything without a 'not working' example.

But since it's only a tiny code:

Code: Select all

UseZipPacker()

If CreatePack(0, "c:\tmp\test.zip")
  ClosePack(0)
EndIf
If I open the file c:\tmp\test.zip with a hex viewer it starts with PK.

So again: without your code wich is not working ...
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Help with Packer, please. - Zip signature

Post by davido »

@infratec,
Thank you for taking the trouble to help.
Apologies for not supplying a code sample. :oops:

Since it is obvious that my code is bad, I'll go away and try to set it aright.
DE AA EB
User avatar
mk-soft
Always Here
Always Here
Posts: 5313
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Help with Packer, please. - Zip signature

Post by mk-soft »

Code: Select all

; TOP by mk-soft

DataSection
  EmptyZip:
  Data.a 'P', 'K', 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  EndEmptyZip:
EndDataSection

Procedure CreateEmptyZipFile(FileName.s)
  Protected file
  file = CreateFile(#PB_Any, FileName)
  If file
    WriteData(file, ?EmptyZip, 22)
    CloseFile(file)
    ProcedureReturn #True
  Else
    ProcedureReturn #False
  EndIf
EndProcedure

f.s = SaveFileRequester("Save", "", "*.zip", 0)
If f
  CreateEmptyZipFile(f)
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply