PureZIP library : ZIP / UNZIP files

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

Moderator: gnozal

Micko
Enthusiast
Enthusiast
Posts: 244
Joined: Thu May 24, 2007 7:36 pm
Location: Senegal
Contact:

Post by Micko »

Hi gnozal i try but i hav the same problem can you help me why my last code please ?
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

Hi, gnozal.

This is not working on my computer:

Code: Select all

Procedure MSSQL_MakeBackup(dbName.s, destFolder.s)
	Protected string.s, bckFile.s, zipFile.s
	
	bckFile = GetTemporaryDirectory() + dbName + ".bck"
	string = "BACKUP DATABASE " + dbName + " TO DISK = '" + bckFile + "'  WITH INIT"
	
	If Not DatabaseQuery(0, string)
		MessageRequester("Error", "Error while creating backup!")
		End
	EndIf
	
	zipFile = destFolder + "\" + dbName + ".zip"
	If PureZIP_Archive_Create(zipFile, #APPEND_STATUS_CREATE)
		PureZIP_Archive_Compress(bckFile, #False)		
		PureZIP_Archive_Close()
	Else
		MessageRequester("Error", "Error creating ZIP file!")
	EndIf
	
	If FileSize(bckFile) > -1
		If DeleteFile(bckFile)
			ProcedureReturn #True
		EndIf
	EndIf
EndProcedure
It creates a ZIP file but the file inside has the file size of 0. PureZip_Archive_Compress() returns -1. Am I doing something wrong?

[EDIT] Sorry I copy & pasted the wrong code. :oops:
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

[EDIT] Hmm... I spent all Sunday trying to figure it out. It seems that PureZIP won't find the file I'm trying to compress even if it's there and it will add a zero bytes file. I've tried several ways of detecting what's wrong, tried to isolate the code, made all variables show in the debug output.

Still I can't make this file get into my ZIP file. Only if I add a break point and follow its execution step by step.

Please, help. Thanks a lot for the great tool.

[EDIT #2]
I found out what it is. DatabaseUpdate() returns 1 too soon while SQLServer engine is still creating the backup file. So when I'm adding the file into the ZIP file, the file is still incomplete leading to the error described. Sorry for assuming that it was a PureZIP problem. I was too quick on it because my time is a little scarse so I imagined lots of things.

Thank you for such a wonderful tool.
nicolaus
Enthusiast
Enthusiast
Posts: 456
Joined: Tue Aug 05, 2003 11:30 pm
Contact:

Post by nicolaus »

Hi gnozal

I have found a link error with PureZIP.

If you use the "UsePNGdecoder()" from PB and your PureZIP you cant compile the code and it shows this message:
"POLINK: error: Symbol '_inflate_copyright' is multiply defined ('PureZIP_LIB_1_UNICODE:inflatress.obj' and 'ImagePluginPNG:inflatress.obj')"

I think you must channge this in your lib or you ask FRED very friendly that he channge it in PB :lol:

regards,
Nico

[EDIT]
testing with pb 4.1b3 with vista home premium 32 bit
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

This is an old problem.
nicolaus
Enthusiast
Enthusiast
Posts: 456
Joined: Tue Aug 05, 2003 11:30 pm
Contact:

Post by nicolaus »

DoubleDutch wrote:This is an old problem.
Aha, and wat i can do to fix this problem?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

nicolaus wrote:
DoubleDutch wrote:This is an old problem.
Aha, and wat i can do to fix this problem?
I don't know. Both PureZIP and the PNG codec use ZLIB, hence the warning I guess.
What you could do :
- use another image format / codec
- try some linker options, like FORCE:MULTIPLE
- ask Fred / Freak what to do :wink:
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
xgp
Enthusiast
Enthusiast
Posts: 128
Joined: Mon Jun 13, 2005 6:03 pm

Post by xgp »

Hi!, first of all, congratulations on this very nice libray of yours! Great job!
I want to ask yuo something, is it possible to just use the UnpackMemory function? I mean, i just need to decompress some memory area on a program i am about to finish, but i think that, whenever i use that function, i am also including all the functions that exist in the library?.

I am basing my sentence because, so far, my program weights ~110kb, but after implementing the "PureZIP_UnpackMemory" it grows to ~134kb.
I know, the extra size nowadays have little importance, but, out of just curiosity, i would like to know some more about this case.

Without anything more to say, Regards and keep you up with the good work so far!

xgp
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

xgp wrote:I want to ask yuo something, is it possible to just use the UnpackMemory function? I mean, i just need to decompress some memory area on a program i am about to finish, but i think that, whenever i use that function, i am also including all the functions that exist in the library?.
If you don't need the ZIP functions, try using the zlib static library directly (available on zlib site for example).

Code: Select all

Import "zlib.lib"
  ZLIBCompress(*DestBuffer, *DestBufferLen, *SourceBuffer, SourceBufferLen.l) As "_compress@16"
  ZLIBUnCompress(*DestBuffer, *DestBufferLen, *SourceBuffer, SourceBufferLen.l) As "_uncompress@16"
EndImport
Or you could use the genuine PB pack functions ...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
xgp
Enthusiast
Enthusiast
Posts: 128
Joined: Mon Jun 13, 2005 6:03 pm

Post by xgp »

Wow, quick response!
I've tested, but i am afraid the size grows the same!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

xgp wrote:Wow, quick response!
I've tested, but i am afraid the size grows the same!
Well, then it seems like PB links all the static library, and not only the necessary functions.
Maybe if you extract the .obj files (POLIB /EXPLODE ZLIB.LIB) from the .lib and then try to import the .obj files (compress.obj + uncompr.obj + ...?), it would work ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
xgp
Enthusiast
Enthusiast
Posts: 128
Joined: Mon Jun 13, 2005 6:03 pm

Post by xgp »

gnozal wrote:Well, then it seems like PB links all the static library, and not only the necessary functions.
Maybe if you extract the .obj files (POLIB /EXPLODE ZLIB.LIB) from the .lib and then try to import the .obj files (compress.obj + uncompr.obj + ...?), it would work ?
Possibly i am doing something wrong, but at the end, i got the pretty much the size as if i were importing the whole .lib. I guess then, there's nothing to do against it.

Here's how i've done:

Code: Select all

POLIB /EXPLODE zlibstat.lib
Then, on the .pb file, i had to keep importing other .obj files because of the "unresolved externanl symbol ..." error.

Code: Select all

Import "inflate.obj"
EndImport
Import "inftrees.obj"
EndImport
Import "adler32.obj"
EndImport
Import "crc32.obj"
EndImport
Import "zutil.obj"
EndImport
Import "inffas32.obj"
EndImport
Import "uncompr.obj"
  ZLIBUnCompress(*DestBuffer, *DestBufferLen, *SourceBuffer, SourceBufferLen.l) As "_uncompress@16" 
EndImport
I am doing something wrong? I am uncertain about this because this was the first time i played with import and .lib or .obj files.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

xgp wrote:Possibly i am doing something wrong, but at the end, i got the pretty much the size as if i were importing the whole .lib. I guess then, there's nothing to do against it.
Probably not.
There is one thing though : if you know C, I guess you could try to create a new library by compiling only the compress / uncompress sources.
xgp wrote:I am doing something wrong? I am uncertain about this because this was the first time i played with import and .lib or .obj files.
No, seems good to me.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Micko
Enthusiast
Enthusiast
Posts: 244
Joined: Thu May 24, 2007 7:36 pm
Location: Senegal
Contact:

Post by Micko »

hi gnozal
take a look here please!http://www.purebasic.fr/french/viewtopic.php?t=7167
Micko
Enthusiast
Enthusiast
Posts: 244
Joined: Thu May 24, 2007 7:36 pm
Location: Senegal
Contact:

Post by Micko »

Gnozal can purezip support an other archive format ? like ace, tar... or just zip archive
Post Reply