<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>ZIP file reader encapsulated in PACKFILE functions</title>
		<link>http://www.allegro.cc/forums/view/467091</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 09 Mar 2005 05:27:46 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>A few days ago I downloaded the 4.1.18 WIP. I noticed the packfile functions used vtables since 4.1.18. So immediately I thought finally zip support!</p><p>Anyway, I&#39;ve been writing the attached zip file reader today, and I need some people to test it and I need some feedback, so it would be great if you could just make a little test with it and report back here whether you had any problems.</p><p>You need Allegro 4.1.18 and zlib installed.</p><p>documentation (also in zipfile.h):
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="c">/* Usage example:</span></td></tr><tr><td class="number">2</td><td><span class="c"> *  Suppose you have a file archive.zip containing the files</span></td></tr><tr><td class="number">3</td><td><span class="c"> *  foo and bar, you would read from them as follows:</span></td></tr><tr><td class="number">4</td><td><span class="c"> *</span></td></tr><tr><td class="number">5</td><td><span class="c"> *  PACKFILE *zip, *foo, *bar;</span></td></tr><tr><td class="number">6</td><td><span class="c"> *</span></td></tr><tr><td class="number">7</td><td><span class="c"> *  zip = pack_fopen_zip_dir("archive.zip");</span></td></tr><tr><td class="number">8</td><td><span class="c"> *</span></td></tr><tr><td class="number">9</td><td><span class="c"> *  if (!zip) { show error message }</span></td></tr><tr><td class="number">10</td><td><span class="c"> *</span></td></tr><tr><td class="number">11</td><td><span class="c"> *  foo = pack_fopen_zip(zip, "foo");</span></td></tr><tr><td class="number">12</td><td><span class="c"> *  bar = pack_fopen_zip(zip, "bar");</span></td></tr><tr><td class="number">13</td><td><span class="c"> *  pack_fclose(zip);</span></td></tr><tr><td class="number">14</td><td><span class="c"> *</span></td></tr><tr><td class="number">15</td><td><span class="c"> *  if (!foo || !bar) { show error message }</span></td></tr><tr><td class="number">16</td><td><span class="c"> *</span></td></tr><tr><td class="number">17</td><td><span class="c"> *  { read from packfiles foo and bar like</span></td></tr><tr><td class="number">18</td><td><span class="c"> *    you read from any other packfile }</span></td></tr><tr><td class="number">19</td><td><span class="c"> *</span></td></tr><tr><td class="number">20</td><td><span class="c"> *  pack_fclose(foo);</span></td></tr><tr><td class="number">21</td><td><span class="c"> *  pack_fclose(bar);</span></td></tr><tr><td class="number">22</td><td><span class="c"> */</span></td></tr></tbody></table></div></div><p>

EDIT: attached new version<br />EDIT: attached new version
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobi Vollebregt)</author>
		<pubDate>Sun, 06 Mar 2005 01:22:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sweet, I&#39;ll try it later, but it sounds really cool.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (razor)</author>
		<pubDate>Sun, 06 Mar 2005 02:29:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve thought for a while that this was the way to go. Then we won&#39;t need the dat utility any more; we can just use (Win)Zip.</p><p>Nice one Tobi!</p><p>Pete
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Sun, 06 Mar 2005 03:40:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve seen a few games using zip for compression.. It is really great that we now have an addon to do it:). Thanks a lot!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Avenger)</author>
		<pubDate>Sun, 06 Mar 2005 03:42:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Add a complete example, I&#39;m too lazy to try it without one <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /> Sounds very useful in any case.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Sun, 06 Mar 2005 03:48:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This sounds simply awesome. I&#39;ll grab a copy of it and see if I can check it out.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sun, 06 Mar 2005 05:01:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>have i missed the point ?<br />why use compression ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (A J)</author>
		<pubDate>Sun, 06 Mar 2005 14:06:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
To save space?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Richard Phipps)</author>
		<pubDate>Sun, 06 Mar 2005 14:52:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks!</p><p>I&#39;ll do some more testing by myself today and then I&#39;ll upload it to the depot. I&#39;ll also add an example.</p><p>And btw, the main reason IMO to use zip for game data is because of easy maintenance, not necessarily compression (you would zip the download anyway). Just make a dir with game data, right click-&gt;add to zip and voilà, there&#39;s your datafile.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobi Vollebregt)</author>
		<pubDate>Sun, 06 Mar 2005 15:23:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>not necessarily compression (you would zip the download anyway)</p></div></div><p>
It&#39;s still nice and polite to leave as small of a foot print on disk as reasonably possible.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Sun, 06 Mar 2005 15:34:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>hard drive space is cheap.<br />too cheap.. so cheap it is not worth the effort of compressing individual bits.<br />i no longer see it as useful, rather as a distraction and possible cause of problems.  not part of the solution.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (A J)</author>
		<pubDate>Sun, 06 Mar 2005 18:14:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I would like to use uncompressed zips in my program.. mainly because that would make my game easier to modify.. And it is much better to have one big file instead of thousands of small ones
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Avenger)</author>
		<pubDate>Sun, 06 Mar 2005 18:23:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
it is not worth the effort of compressing individual bits.
</p></div></div><p>

an &quot;individual bit&quot; can&#39;t be compressed any further:P<br />Sorry for the OT but this silly joke felt so burning under my nails.;D
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dennis)</author>
		<pubDate>Sun, 06 Mar 2005 18:38:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It is nice to have all your files in one file. That way you don&#39;t flood peoples system with files, I know that I&#39;ve noticed windows deals with lots of files much slower than a single large file.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (razor)</author>
		<pubDate>Sun, 06 Mar 2005 18:54:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve updated the zip attached to my first post. Fixed some unicode handling with trace, added some assertions and an example.c and example.zip</p><p>btw, I&#39;m thinking about a way to read the directory entries from the zip file. Now I would like to know, would you think it&#39;s useful to know more about a file than name+size (like crc, attributes, compressed size, comment, etc.)? And what API would you prefer?</p><p>Like this? Or something else?
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">int</span> zip_get_num_dir_entries<span class="k2">(</span><a href="http://www.allegro.cc/manual/PACKFILE" target="_blank"><span class="a">PACKFILE</span></a> <span class="k3">*</span>f<span class="k2">)</span><span class="k2">;</span>
<span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>zip_get_name<span class="k2">(</span><a href="http://www.allegro.cc/manual/PACKFILE" target="_blank"><span class="a">PACKFILE</span></a> <span class="k3">*</span>f, <span class="k1">int</span> i<span class="k2">)</span><span class="k2">;</span>
<span class="k1">long</span> zip_get_size<span class="k2">(</span><a href="http://www.allegro.cc/manual/PACKFILE" target="_blank"><span class="a">PACKFILE</span></a> <span class="k3">*</span>f, <span class="k1">int</span> i<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobi Vollebregt)</author>
		<pubDate>Sun, 06 Mar 2005 19:33:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It could be interesting to use an API similiar to allegro&#39;s directory API:</p><p>al_find_first, al_find_next, al_find_close, for_each_file_ex</p><p>But then, I&#39;d actually prefer to get the number of entries and then use an index, myself <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>Hm, and this makes me wonder.. haven&#39;t some people worked on designs for a simple virtual file system? Seems like a good time to look at such designs now - they already must include an API to list files and get various information about them.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Sun, 06 Mar 2005 19:51:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s some nice work you did there! Great job! About the additional information (crc, attributes etc.) I&#39;d say it wouldnt hurt to have them ready <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Indeterminatus)</author>
		<pubDate>Sun, 06 Mar 2005 20:09:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>hard drive space is cheap.<br />too cheap.. so cheap it is not worth the effort of compressing individual bits.<br />i no longer see it as useful, rather as a distraction and possible cause of problems. not part of the solution.</p></div></div><p>
I whole heartedly disagree. Hard drive space may be cheaper, but not everyone is able to upgrade as needed. The more games that go by uncompressed, the more hard drive space will be needed, thus forcing the user to upgrade to bigger drives. Cheap or not, it&#39;s still $$$ not everyone has or is able to spend. &quot;It&#39;s cheap&quot; is a poor excuse because &quot;it&#39;s cheap&quot; is still too expensive for some. Do you think I&#39;d be stuck with a Geforce 2 MX video card if I could get a Geforce 4 Ti because &quot;it&#39;s cheap&quot;?</p><p>Durring development is a different matter of course, but if HD space was such a non-issue, why use PNG, MP3/Ogg, and MPG/AVI/Ogg at all when TGA, WAV, and uncompressed BMPs have been around forever (and are directly supported by Allegro) and serve the same purpose? Now, <i>if</i>, and that&#39;s a big if, all your game data is precompressed PNG and Ogg (and even FLAC), then I can see compressed zip files as being unneeded (and potentially hindering), but your average game (especially average Allegro game) has plenty of uncompressed data.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Mon, 07 Mar 2005 03:01:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The API is now like this:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">int</span> zip_get_num_dir_entries<span class="k2">(</span><a href="http://www.allegro.cc/manual/PACKFILE" target="_blank"><span class="a">PACKFILE</span></a> <span class="k3">*</span>f<span class="k2">)</span><span class="k2">;</span>
<span class="k1">char</span> <span class="k3">*</span>zip_get_name<span class="k2">(</span><a href="http://www.allegro.cc/manual/PACKFILE" target="_blank"><span class="a">PACKFILE</span></a> <span class="k3">*</span>f, <span class="k1">int</span> i, <span class="k1">char</span> <span class="k3">*</span>dest<span class="k2">)</span><span class="k2">;</span>
<span class="k1">long</span> zip_get_size<span class="k2">(</span><a href="http://www.allegro.cc/manual/PACKFILE" target="_blank"><span class="a">PACKFILE</span></a> <span class="k3">*</span>f, <span class="k1">int</span> i<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

I&#39;m gonna send a mail to matthew to add it to the resource dir. I think the latest version (only on my HD at this moment) is fully unicode-aware now (even when debugging) and all others things seems to be fine. If you want to know the crc or other file props I&#39;ll just let you hack into my sources <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />, I don&#39;t really feel the need to add it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobi Vollebregt)</author>
		<pubDate>Mon, 07 Mar 2005 19:34:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
an &quot;individual bit&quot; can&#39;t be compressed any further
</p></div></div><p>
Lzip will prove you wrong!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Steve Terry)</author>
		<pubDate>Tue, 08 Mar 2005 04:13:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
With Quantum Mechanics it could.. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Richard Phipps)</author>
		<pubDate>Tue, 08 Mar 2005 04:15:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Has anyone thought of adding tar.gz support?  Because I generally have smaller files with it, like 1/5 smaller.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jose Cuervo)</author>
		<pubDate>Tue, 08 Mar 2005 06:28:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>tar.gz would be more difficult, as the directory format (tar) is compressed globably, so it would have to be completely uncompressed and loaded into memory before anything can be read.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 08 Mar 2005 06:35:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>And if you want better compression, you should use <a href="http://www.7-zip.org/sdk.html">LZMA</a>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Daniel Schlyder)</author>
		<pubDate>Tue, 08 Mar 2005 06:51:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Or if you want a truely fast decompressor, try <a href="http://www.oberhumer.com/opensource/lzo/">LZO</a>. On a p1 133 it does about 16MB/s, LZMA does about 8MB/s on a p3 1ghtz...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 08 Mar 2005 07:02:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Thomas said:</div><div class="quote"><p>
Or if you want a truely fast decompressor, try LZO
</p></div></div><p>
Heh.  You know, I&#39;ve read about that algorithm before, and I only remembered after seeing the pic on the main page.  &quot;Space Grade Technology&quot;.</p><p>But that shouldn&#39;t overshadow Zip support; it&#39;s awesome.  I&#39;m grateful for the people who made it possible.  Thanks Tobi, vtable authors, et. al.  I&#39;ll do some testing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Gideon Weems)</author>
		<pubDate>Tue, 08 Mar 2005 08:43:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>We should add this right into allegro, after it is more complete. Then that would make allegro dependent on zlib, but if the license allows it, we could include the needed zlib code right in allegro
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Wed, 09 Mar 2005 02:23:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
We should add this right into allegro, after it is more complete. Then that would make allegro dependent on zlib, but if the license allows it, we could include the needed zlib code right in allegro
</p></div></div><p>
Nah, the better route would be to include this into an extra distribution, which contains allegro + some useful addons, all packed up as a single download and easy to install.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Wed, 09 Mar 2005 03:45:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>As far as that goes, what about the licensing of Allegro? zlib isn&#39;t restrictive <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /> It&#39;s what I release under.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Wed, 09 Mar 2005 03:50:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>zlib is more restrictive than Allegro, but only in stuff that doesn&#39;t matter. (Ie, don&#39;t abuse our generosity vs please don&#39;t abuse our generosity.)</p><p>Allegro could take zlib and bundle it, but then Allegro&#39;s license would have be to be modified to be &quot;Giftware, with some parts under the zlib license&quot;.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 09 Mar 2005 03:57:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think that may be a good idea myself.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Wed, 09 Mar 2005 04:43:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>As Elias said, I think this should be a supported or approved or bundled or gift wrapped or whatever addon, not part of the vanilla Allegro distribution.<br />Depending on zlib shouldn&#39;t be too much of a problem for the bigger package. We&#39;d want PNG support in there anyway.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 09 Mar 2005 04:48:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes.. maybe with 4.2.0, someone will create such a thing. A distribution which has zlib, libpng, loadpng, AllegroGL, glyphkeeper, jpgalleg, whatever else, all bundled together. The make process then also would build the examples and documentation of all the addons. But there still would be no need to move zlib into allegro&#39;s CVS repository.. everything would stay nicely modular (except the allegro core itself, which still is quite big <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Wed, 09 Mar 2005 04:56:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
Maybe there should be a stripped down Allegro core then since this will get  pretty big in terms of file size.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Richard Phipps)</author>
		<pubDate>Wed, 09 Mar 2005 05:03:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There will always be a vanila allegro distro.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 09 Mar 2005 05:27:46 +0000</pubDate>
	</item>
</rss>
