Zip Extraction

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Ooblik
Posts: 38
Joined: Thu Apr 10, 2008 1:47 pm

Zip Extraction

Post by Ooblik »

Anybody have a source code example on extracting zip files?
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

It's the same as on a PC. Just use zlib - it's part of the libraries in the toolchain for a reason.
>.>
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Well you do need to but something around zlib which handles the zip format itself but yes not hard :)
willow :--)
Posts: 107
Joined: Sat Jan 13, 2007 11:50 am

Post by willow :--) »

A working implementation exists in JGE++'s source code:
http://code.google.com/p/wagic/source/b ... /src/unzip
http://code.google.com/p/wagic/source/b ... System.cpp

But as it's been said, there's nothing PSPecific about this
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

i posted a library that was made using minizip that works on psp on my website kehon.izfree.com but not to sure how its doing now
Ooblik
Posts: 38
Joined: Thu Apr 10, 2008 1:47 pm

Post by Ooblik »

THANKS coolkehon your library still works perfectly!

Now I have a new problem:

Code: Select all

...		if(unzGetCurrentFileInfo(zipFd, &curZipFileInfo, fNameBuf, sizeof(fNameBuf), NULL, 0, NULL, 0) == UNZ_OK) {
			if(curZipFileInfo.uncompressed_size > 0) {
				printf("Allocate %d Bytes for %s\n", (int)(curZipFileInfo.uncompressed_size)+1, fNameBuf);
				
				fileBuff = (char *)realloc(fileBuff, curZipFileInfo.uncompressed_size+1);...
This only allocates 4 bytes (int ?). How can I fix it? Sorry I'm new to dynamic memory allocation XD

I know this is probably some stupid little thing I'm just not thinking of...
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Is fileBuff used before? Is it null? Check the realloc return value. If fileBuff isn't already assigned to an allocated address then it has to be null for realloc to work.
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

i did this once by accident it was a pointer problem dont rember if it was like this or what but i was writting a pointer instead of the data to the pointer or vice versa make sure you have all the info correct with pointers because the size of a pointer i believe is 4 bytes
Ooblik
Posts: 38
Joined: Thu Apr 10, 2008 1:47 pm

Post by Ooblik »

coolkehon wrote:i did this once by accident it was a pointer problem dont rember if it was like this or what but i was writting a pointer instead of the data to the pointer or vice versa make sure you have all the info correct with pointers because the size of a pointer i believe is 4 bytes
Yeah its allocating the size of the pointer int (4 bytes) not the value of the pointer represented as an integer... if that makes sense...
Post Reply