Zip / Unzip options within an APP?

What are some options for zipping and unzipping files within a Clarion app?

I don’t remember what I used for that back in the day and a Google search isn’t helpful.

I think there’s some sort of compression built in somewhere in the RTL
I might have to do some searching.

1 Like

Lszip from lindersoft

1 Like

Lszip from lindersoft

Ah, that was it. I was able to locate it in my archives and I’m in business.

Thank you.

You can Zip / UnZip in a BAT file calling PowerShell version 5 which is in Windows 10. No need to install 7Zip or anything. Handy for some quick simple work.

REM Compress Folder %BakFolder% into %BakZip%
powershell Compress-Archive -Path %BakFolder%\* -DestinationPath %BakZip%

https://ss64.com/ps/compress-archive.html


https://ss64.com/ps/expand-archive.html

1 Like

Thanks Carl. I did dig up my old LSZip license – and even some of my old code from 2008 – and I have zipping/unzipping working now.

You can work with ZIP archives from the Windows shell.

CreateZIPFile        PROCEDURE  (String Source_,String ZipFile_,Byte NoMess_)
Loc:Object           CSTRING(65) 
Loc:RetValue         BYTE(False) 
  CODE
  If SaveFile(ZipFile_,'<80><75><5><6>' & All(Chr(0),18))  ! Create empty ZIP File

     Loc:Object              = Create(0,Create:Ole)
     Loc:Object{Prop:Create} = 'Shell.Application'
     If ~NoMess_ then Loc:Object{Prop:ReportException} = True.   ! Display message

     Loc:Object{'NameSpace("' & Clip(ZipFile_) & '").CopyHere("' & Clip(Source_) & '",20)'}

     Loop until Loc:Object{'NameSpace("' & Clip(Left(ZipFile_)) & '").Items().Count'} = 1
       Loop 100 times
         Yield
       end
     end

     If Exists(ZipFile_) then Loc:RetValue = True.
     Loc:Object{Prop:Deactivate}
  end

  Return Loc:RetValue
3 Likes

You can work with ZIP archives from the Windows shell.

Thank you. I already have LSZip working with my app, but I’ll note your suggestion for the future.

Just for your information: there is a public domain zip class (it is a wrapper for zlib).

Just for your information: there is a public domain zip class (it is a wrapper for zlib).

It would be good to link to that class here in case someone else searches.

here is a link to the class and an example:

If anybody have a question, just ask. regards

ClarionZipClass.zip (109.8 KB)

3 Likes

Thank you! I’ll have a look.

Thanks, I saved it for future. Currently I’m still using Jzip, which uses 7zip and works ok.

Here’s an update to my scenario:

  • I had to abandon using LSZip because it would consistently GPF when zipping large amounts of data. With my app, the total file size can easily be 5-10 GB. I suspect that the issue is the age of LSZip and that the version of the zip spec that it uses was limited. (My LSZip was from 2008.)
  • With @John_Hickey’s help, I implemented the ClarionZipClass (linked to above). It worked with the file sizes, but while 7Zip would compress 10 GB of photos in about 30 seconds, the class was taking about 2.5 hours (!!).
  • So I switched to using the 7Zip CLI, which was simple. e.g. run("7z a archivename.zip filemask.ext"). That worked well, could easily handle the file sizes, and was very fast (e.g. 10 GB of photos took about 30 seconds to zip up), but I wanted to show a progress bar so I started looking at OddJobs.
  • In the meantime, John figured out what was causing the ClarionZipClass to run so slowly and also added a progress bar to the class. What was taking 2.5 hours now takes less than 2 minutes. It’s slower than 7Zip, but the wait for my usage is trivial so that’s what I’m using now.

I think John was going to do a ClarionLive about the code. Hopefully he shares his updated code.

(I mistakenly posted this update at Create a ZIP file from a Clarion Application - #3 by sjreryan. Posting it here as well so that this thread is complete.)

You can also take a look at JZip:
https://strategyonline.net/docs/clarion/jzip.htm

I know Gary has made almost all his utilities free many years ago.

Interesting. I didn’t know that. Are they available to download somewhere? I tried the download on the link you posted and they are dead. Is anyone updating those products or are they just set in time?

And whatever happened to Gary? He was so prolific back in the day.

I know at some stage there was a list where you could download all the free tools on Gary’s site.
I think he also had the installation passwords listed on his site.
I can’t find it now.

I don’t think anybody has taken Gary’s tools over.

Apparently Gary is still around somewhere.
I tried to contact Gary numerous times with no luck.

That’s too bad, but times change and people move on to new things.

Do you happen to have JZip to share? I wouldn’t mind having a look at it’s unzipping capabilities.

Hello,

Do you have an example to unzip the file using the CZipClass?

Thank you.

1 Like

Do you have instructions on how to implement this properly? I put the files where I thought they should go then used the example code to try it myself. I got my code to compile, but when I run it I get a GPF when it gets to my data section where I try to instantiate the zip with:
MyCZip CZipClass