January 28, 2012, 11:14:43 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: ZipStream BlitzMax module  (Read 8654 times)
Koriolis
Administrator
Sr. Member
*****
Posts: 332


View Profile Email
« on: August 11, 2007, 06:51:04 PM »

This module adds two new stream protocols for zip support in streams : "zip" and "zip?"
"zip" is for reading files that are in the specified zip.
"zip?" is for reading files that are in the specified zip OR (if not found in the zip) on the hard drive (or any other location supported by streams).

The zip stream works over another stream. This means that you can not only access zip files on the hard drive, but also zp files that are incbined, or even zip files within other zip files, and so on.

Example of valid urls: "zip::myGame/myZip.zip//someFile.txt", or even "zip::incbin::myGame/myZip.zip//someFile.txt" if the zip file is incbined.

So you could do by example: LoadText("zip::myGame/myZip.zip//someFile.txt")

Use as you please.

UPDATED on 31 aug 2008 : ZipStream is now seekable, making it usable practically anywhere you want. Tested with zipped ogg files, and it works. Note that you'll need "koriolis.bufferedstream", available in a separate thread.

LAST UPDATE on 22 jun 2010: Fixed crash when attempting to close an already closed ZipStream. Corrected misspell in SetZipStreamPassword and ClearZipStreamPassword (but also kept misspelled version for backward compatibility).

Link to corresponding thread on BRL's official site: http://blitzbasic.com/Community/posts.php?topic=71734

* koriolis.mod.zip (76.37 KB - downloaded 228 times.)
« Last Edit: July 14, 2010, 10:08:30 PM by Koriolis » Logged
Filax
Newbie
*
Posts: 1


View Profile
« Reply #1 on: August 13, 2007, 12:03:23 AM »

Many thanks Smiley work fine !
Logged
dimanche13
Newbie
*
Posts: 1


View Profile Email
« Reply #2 on: February 05, 2008, 10:44:27 AM »

Thanks to you, for shared this module.
Logged
StuC
Newbie
*
Posts: 2


View Profile
« Reply #3 on: March 27, 2008, 10:01:03 AM »

Superb work.


« Last Edit: March 27, 2008, 10:08:31 AM by StuC » Logged
StuC
Newbie
*
Posts: 2


View Profile
« Reply #4 on: March 27, 2008, 10:43:14 AM »

Reading thru the many posts, it appeared that SEEKING was now working ?

I can load in OGG, wav  file all fine, but images are just returning NULL.

 

Ive found out why.  I am using subfolders in the ZIP file and it seems that "\" needs to be replaced with "/" for it to work.


« Last Edit: March 27, 2008, 10:58:39 AM by StuC » Logged
Koriolis
Administrator
Sr. Member
*****
Posts: 332


View Profile Email
« Reply #5 on: March 28, 2008, 08:33:19 AM »

OK, I'll look into fixing this. It should definitely work right way.

EDIT: I guess I was a bit tired when I wrote the above, or didn't undestanrd well your problem. It is in fact totally normal: just always use '/' and not '\'. This is logical: pathes inside zips must use "/", not "\". And in fact, because BlitzMax supports "/" in file pathes even on Windows, you can simply use "/" everywhere, both for the zip path AND the file path inside the zip.
« Last Edit: June 09, 2008, 06:54:47 PM by Koriolis » Logged
xstreme
Newbie
*
Posts: 1


View Profile Email
« Reply #6 on: August 03, 2008, 05:25:38 PM »

great work

www.xstreme.it
Logged
BozRetro
Newbie
*
Posts: 2


View Profile Email
« Reply #7 on: November 16, 2008, 06:00:05 PM »

Great work on the ZIPStream. It's working fine.

Unfortunately I seem to be having a problem when trying to set a password. If I put "SetZipStreamPassword( "foo.zip", "bar" ) for instance, BlitzMax always comes up with "Compile Error: Identifier 'SetZipStreamPassword' not found."  A it weird seeing as the Zip Stream part itself seems to work fine.

Am I missing something here? I've rebuilt the modules ZipStream and Bufferedstream, and used "Import koriolis.zipstream" at the start of the program.

Thanks!
Logged
Koriolis
Administrator
Sr. Member
*****
Posts: 332


View Profile Email
« Reply #8 on: November 17, 2008, 01:09:31 AM »

Oooop,s I checked, and the function is misspelled. Try with SetZipStreamPasssword (3 S).
Apparently not so many people use passworded zips, you're the first one to report this.
I'll correct the module later.
Logged
BozRetro
Newbie
*
Posts: 2


View Profile Email
« Reply #9 on: November 17, 2008, 07:49:36 AM »

Thanks for your quick reply, K Smiley

Ah, that did the trick... I'll keep my eyes open when any changes to spelling are made. Actually for now I've just made a "wrapper function", so it will be a 10-second change.

Keep up the great work!

Boz.
Logged
Ratchet
Newbie
*
Posts: 4


View Profile
« Reply #10 on: December 25, 2008, 02:59:06 PM »

If there a way to check if a file does exists in the zip file?
Logged
Koriolis
Administrator
Sr. Member
*****
Posts: 332


View Profile Email
« Reply #11 on: December 26, 2008, 10:50:22 AM »

There is no support for inspecting the content of the whole zip (for this, you can use the ZipEngine module). However, for checking the presence of a single file you can simply open the file using the zip protocol, and check that the returned stream is not null.
Logged
Ratchet
Newbie
*
Posts: 4


View Profile
« Reply #12 on: December 26, 2008, 11:36:48 AM »

I have trouble with subfolders inside the zip. I made a simple test programm for loading a font, a image and a sound from a zip. Workes great if the files are in the zip's root folder. But if I use sub folders my program always crashes ("Error reading from stream" on loading the font and the Image variable is Null). It looks like the files are not found in the zip. Maybe my paths are wrong? I try to read the files like this:

Workes fine if files in zip's root
Code:
i: TImage = LoadImage("zip::Archiv.zip//cursor_normal.png")

Doesn't workes because files are in subfolders
Code:
i: TImage = LoadImage("zip::Archiv.zip//graphics//cursor_normal.png")

I've tried much with the // using just one or putting them before the zip name but it does'n help.
What am I doing wrong?
« Last Edit: December 26, 2008, 11:43:36 AM by Ratchet » Logged
Koriolis
Administrator
Sr. Member
*****
Posts: 332


View Profile Email
« Reply #13 on: December 26, 2008, 05:04:01 PM »

You must only use a double slash to separate the zip's path from the file (inside the zip) 's path.
So typically you'll always have the double slash after ".zip", but nowhere else :
Code:
i: TImage = LoadImage("zip::Archiv.zip//graphics/cursor_normal.png")
The above should work without any problem.
Logged
Ratchet
Newbie
*
Posts: 4


View Profile
« Reply #14 on: December 26, 2008, 05:11:44 PM »

Thanks, workes great now!
Logged
Pages: [1] 2 3
  Print  
 
Jump to:  

 
Powered by MySQL Powered by PHP bluBlur Skin © 2006, hbSkins
Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!