• Welcome to SQLitening Support Forum.
 

News:

Welcome to the SQLitening support forums!

Main Menu

ZLib Wrapper Routines

Started by Rolf Brandt, February 23, 2011, 11:08:56 AM

Previous topic - Next topic

Rolf Brandt

Hello Fred,
I was just toying with those routines:
http://www.sqlitening.com/support/index.php?topic=3254.0

Can they be used to create zip files from existing files or directories also?
Is there an example?
I like to cook with wine - sometimes I even add it to the food.
www.rbsoft.eu

Fred Meier

Yes, these routines can read/write/create standard zip files.  I will work up some examples and post later.

Rolf Brandt

I like to cook with wine - sometimes I even add it to the food.
www.rbsoft.eu

Fred Meier

I downloaded and reviewed Zipper.Zip and found that Zipper.Bas is a
program that if you compile and run it will create a standard .Zip file
called Test.Zip and then unzip from it.  Let me know if you need more
examples? 

Rolf Brandt

Hello Fred,

what I really need is to programmatically zip an existing file - let's say a .bas or .exe file - or even a complete directory with several files. I could not find out how to do that with the zipper bas ruts.
I like to cook with wine - sometimes I even add it to the food.
www.rbsoft.eu

Fred Meier

This snippet will zip the Ziipper.Bas file to Test.Zip.  Replace
PbMain in Ziipper.Bas with this snippet. 

I just now noticed that there are two i's in "Zipper", my mistake. 

   Local lsA as String
   Local lsZCB as String

   arZipFileInsertOpen "Test.Zip", lsZCB
   open "Ziipper.Bas" for binary lock shared as #1
   get$ #1, lof(#1), lsA
   close #1
   arZipFileInsertPut lsZCB, "Ziipper.Bas", lsA
   arZipFileInsertClose lsZCB


To do a folder, you would have to do someting like following:
   arZipFileInsertOpen "Test.Zip", lsZCB
   for each file in folder
      open file_name for binary lock shared as #1
      get$ #1, lof(#1), lsA
      close #1
      arZipFileInsertPut lsZCB, file_name, lsA
   next
   arZipFileInsertClose lsZCB



Rolf Brandt

That is great, Fred. Thanks a lot!
I like to cook with wine - sometimes I even add it to the food.
www.rbsoft.eu

Fredrick Ughimi

Hello,

Is there a way one can unzip a zipped file using the technique Fred posted a while ago?

Best regards,
Fredrick O. Ughimi<br /><br />fughimi@gmail.com<br />- Freedom lies in being bold -- Robert Frost, Poet

cj

#8
Yes.  I'm not sure this is from his code.                       https://forum.powerbasic.com/forum/user-to-user-discussions/third-party-addons/29121-litezip-liteunzip/page2?t=28376&page=2
copy sqliteningzlib.dll to zlib.dll or change calls.

FUNCTION PBMAIN

   LOCAL lsA, lsB AS STRING
   LOCAL lsZCB AS STRING

   ' zip it
   arZipFileInsertOpen "Text.Zip", lsZCB
   lsA = "This is some data to put in zip file."
   arZipFileInsertPut lsZCB, "MyFile.Txt", lsA
   arZipFileInsertClose lsZCB

   ' unzip it
   arZipFileGetFile "Text.Zip", 1, lsB
   ? lsB
END FUNCTION     
"No email alerts being received"  Please often check back.

Fredrick Ughimi

Hello CJ,

Cool. Really cool.

I would take a closer look later.

Thank you, CJ.
Fredrick O. Ughimi<br /><br />fughimi@gmail.com<br />- Freedom lies in being bold -- Robert Frost, Poet

cj

I know there are also some routines that call SqliteningZlib.dll the same way SQLitening does using AuxRuts if you need them.
"No email alerts being received"  Please often check back.

Fredrick Ughimi

Hello CJ,

Where are these keywords from:

arZipFile...

Don't think they are in the SQLitening help file.

Regards,

Fredrick O. Ughimi<br /><br />fughimi@gmail.com<br />- Freedom lies in being bold -- Robert Frost, Poet

cj

They are from the routines in the download link to zipper.zip
"No email alerts being received"  Please often check back.

Fredrick Ughimi

CJ,

I just tried downloading the zipper.zip and I got:

"404 - Attachment Not Found"
Fredrick O. Ughimi<br /><br />fughimi@gmail.com<br />- Freedom lies in being bold -- Robert Frost, Poet

Fredrick Ughimi

I just downloaded the one you uploaded.
Fredrick O. Ughimi<br /><br />fughimi@gmail.com<br />- Freedom lies in being bold -- Robert Frost, Poet