PureZIP library : ZIP / UNZIP files

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by c4s »

Thank you gnozal.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by gnozal »

Update (PB4.60 version)

Changes :
- new function : PureZIP_Archive_ReadInMemory()
     Open a ZIP archive in memory (data section, resource, ...) for reading.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by MachineCode »

I can't seem to get PureZIP_AddFiles() to use FileMask.s with partial names. For example, I want to recurse a folder and only add files to my zip archive that have "PartialName" in their filename. But when I run the following code, 0 files are added. However, if I change "*PartialName*" to "*.*" then all files are added, as expected.

Does PureZIP not support this format of FileMask? If not, can I please request that it be added? Because at the moment I have to build my own directory list, filter the filenames manually, then add them one-by-one to the zip archive with PureZIP_Archive_Compress(). :(

Code: Select all

MyZIP.s = "C:\Test.zip"
MyFilesToZIP.s = "C:\Temp\*PartialName*" ; This fails, but using *.* works!
Debug PureZIP_AddFiles(MyZIP, MyFilesToZIP, #PureZIP_StorePathAbsolute, #PureZIP_Recursive)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files

Post by gnozal »

Update (PB4.60 version -> V2.21)

Changes :
- PureZIP now uses API function PathMatchSpec() to analyze file masks with wildcards like * or ?.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files

Post by gnozal »

Update (PB4.60 version -> V2.30)

Changes :
- new function PureZIP_Archive_CheckCRC() to check file integrity
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
GWarner
Enthusiast
Enthusiast
Posts: 605
Joined: Fri Jul 24, 2009 1:34 pm
Location: USA

Re: PureZIP library : ZIP / UNZIP files

Post by GWarner »

I just tried to download PureZIP but when I try to open the zip file I'm told that it is corrupt. :(
I had no problem opening any of gnozal's other zip files that I downloaded.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PureZIP library : ZIP / UNZIP files

Post by IdeasVacuum »

...I downloaded it too, no problem though so perhaps yours got broken on the way down. Try again.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
GWarner
Enthusiast
Enthusiast
Posts: 605
Joined: Fri Jul 24, 2009 1:34 pm
Location: USA

Re: PureZIP library : ZIP / UNZIP files

Post by GWarner »

Must be some with the network at work or my work computer because I tried downloading it a bunch of times with the same result.

But at home on my home PC it downloaded and opened without a problem.

Strange.... :?
ruslanx
User
User
Posts: 46
Joined: Mon Jun 06, 2011 8:28 am

Re: PureZIP library : ZIP / UNZIP files

Post by ruslanx »

Hi, a very usefull functions is missed like 'PureZIP_EcryptFileNames',if is posible (I know it is posible for you) can you add a function like this,thanks!

ps: a very usefull function (for me,at least) in combination with PureZIP_SetArchivePassword ...
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files

Post by gnozal »

ruslanx wrote:Hi, a very usefull functions is missed like 'PureZIP_EcryptFileNames',if is posible (I know it is possible for you) can you add a function like this,thanks!
Sorry, PureZIP uses ZLIB, and there is no ZLIB function available for encrypting filenames.

Additionally, standard ZIP encryption is not very strong, so I would not use PkZip like archives for sensible data : 7-Zip offers very strong encryption, very good compression ratios (LZMA algo) and it's free.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
ruslanx
User
User
Posts: 46
Joined: Mon Jun 06, 2011 8:28 am

Re: PureZIP library : ZIP / UNZIP files

Post by ruslanx »

Thanks Gnozal for quick answer ... I will use 7z.exe ... 7z a archive.7z -p123 -mhe *.txt

but I need a 'ProgressionCallback' .... I find a key for 7z -so (write data to stdout)
how I can read info from stdout .. can you give a peace of code or example ..thx.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files

Post by gnozal »

ruslanx wrote:...how I can read info from stdout .. can you give a peace of code or example ..thx.
You may use the process library fonctions.

Below an example executing PING and reading the result.

Code: Select all

Procedure.s ReadProgramStringSafe(ProgramNr) ; ReadProgramString does NOT support Unicode
  ;
  Protected Char.a, ReturnValue.s
  ;
  Static MyReadProgramOffset = 0
  ;
  Shared *MyReadProgramStringBuffer
  ;
  size = AvailableProgramOutput(ProgramNr)
  If size > 0
    ;
    Repeat
      ;
      ReadProgramData(ProgramNr, @Char, 1)
      PokeB(*MyReadProgramStringBuffer + MyReadProgramOffset, Char)
      MyReadProgramOffset + 1
      ;
      If AvailableProgramOutput(ProgramNr) = 0 Or MyReadProgramOffset > 255
        Break
      EndIf
      ;
    Until Char = $0A
    ;
    If Char <> $0A
      ReturnValue = ""
    Else
      PokeB(*MyReadProgramStringBuffer + MyReadProgramOffset, 0)
      ReturnValue = PeekS(*MyReadProgramStringBuffer, -1, #PB_Ascii)
      MyReadProgramOffset = 0
      ReturnValue = ReplaceString(ReturnValue, Chr(13), "")
      ReturnValue = ReplaceString(ReturnValue, Chr(10), "")
    EndIf
    ;
  EndIf
  ;
  ProcedureReturn ReturnValue
  ;
EndProcedure
Procedure IsRemotePCAvailable(RemotePC.s)
  ;
  Protected ConnectionOk, ResponseLine, Prog, FindLast, FindFirst, TimeOut.i
  ;
  Shared IsRemotePCAvailable_IP.s
  Shared *MyReadProgramStringBuffer
  ;
  IsRemotePCAvailable_IP = ""
  ;
  *MyReadProgramStringBuffer = AllocateMemory(2048)
  If *MyReadProgramStringBuffer
    ;
    Prog = RunProgram("ping.exe", RemotePC, GetTemporaryDirectory(), #PB_Program_Open | #PB_Program_Read | #PB_Program_Hide)
    If Prog
      TimeOut = ElapsedMilliseconds() + 5000
      Debug "IsRemotePCAvailable : START -> " + RemotePC
      While ProgramRunning(Prog)
        Response$ = ReadProgramStringSafe(Prog)
        If Response$
          Debug "---> " + Response$
          ResponseLine + 1
          If ResponseLine = 1
            IsRemotePCAvailable_IP = RemotePC
            FindFirst = FindString(Response$, "[", 1)
            If FindFirst
              FindLast = FindString(Response$, "]", FindFirst + 1)
              If FindLast
                IsRemotePCAvailable_IP = Mid(Response$, FindFirst + 1, FindLast - FindFirst - 1)
              EndIf
            EndIf
          ElseIf ResponseLine = 2
            If FindString(Response$, "TTL", 1)
              ConnectionOk = #True
            Else
              IsRemotePCAvailable_IP = ""
            EndIf
            KillProgram(Prog)
            Break
          EndIf
        EndIf
        If ElapsedMilliseconds() > TimeOut
          KillProgram(Prog)
          Break
        EndIf
      Wend
      If ResponseLine = 1
        IsRemotePCAvailable_IP = ""
      EndIf
      CloseProgram(Prog)
      Debug "IsRemotePCAvailable : END"
    Else
      ConnectionOk = -1
    EndIf
    ;
    FreeMemory(*MyReadProgramStringBuffer)
    ;
  Else
    ConnectionOk = -1
  EndIf
  ;
  ProcedureReturn ConnectionOk
  ;
EndProcedure
Debug IsRemotePCAvailable("localhost1")
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
ruslanx
User
User
Posts: 46
Joined: Mon Jun 06, 2011 8:28 am

Re: PureZIP library : ZIP / UNZIP files

Post by ruslanx »

Thanks Gnozal !
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: PureZIP library : ZIP / UNZIP files

Post by kenmo »

This library is great, gnozal, thank you for keeping it going for what, 6 years now?!?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files

Post by gnozal »

kenmo wrote:This library is great, gnozal, thank you for keeping it going for what, 6 years now?!?
Since 2005 (It was PB3.92 at the time iirc) !
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply