<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>How to get all files in a directory with A5</title>
		<link>http://www.allegro.cc/forums/view/606721</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 17 Mar 2011 01:11:31 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I know the older version of Allegro had the for_each_file thing, what should I use with A5 to get all the files in a directory? <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Tue, 15 Mar 2011 22:05:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><span class="source-code"><a href="http://www.allegro.cc/manual/al_read_directory"><span class="a">al_read_directory</span></a><span class="k2">(</span><span class="k2">)</span></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Tue, 15 Mar 2011 23:35:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I figured as much, but what kind of iteration device do I use?! I see nothing in the manual about such devices.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Wed, 16 Mar 2011 19:21:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This will print the name of everything in the passed directory.</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="p">#include &lt;stdio.h&gt;</span>
<span class="number">  2</span><span class="p">#include &lt;allegro5/allegro.h&gt;</span>
<span class="number">  3</span>
<span class="number">  4</span><span class="k1">int</span> main<span class="k2">(</span><span class="k1">int</span> argc, <span class="k1">char</span> <span class="k3">*</span>argv<span class="k2">[</span><span class="k2">]</span><span class="k2">)</span>
<span class="number">  5</span><span class="k2">{</span>
<span class="number">  6</span>   <span class="k1">if</span><span class="k2">(</span>argc <span class="k3">&gt;</span> <span class="n">1</span><span class="k2">)</span>
<span class="number">  7</span>   <span class="k2">{</span>
<span class="number">  8</span>       <a href="http://www.allegro.cc/manual/al_init"><span class="a">al_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  9</span>       
<span class="number"> 10</span>       <a href="http://www.allegro.cc/manual/ALLEGRO_FS_ENTRY"><span class="a">ALLEGRO_FS_ENTRY</span></a><span class="k3">*</span> dir <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_fs_entry"><span class="a">al_create_fs_entry</span></a><span class="k2">(</span>argv<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 11</span>       <span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_open_directory"><span class="a">al_open_directory</span></a><span class="k2">(</span>dir<span class="k2">)</span><span class="k2">)</span>
<span class="number"> 12</span>       <span class="k2">{</span>
<span class="number"> 13</span>           <a href="http://www.allegro.cc/manual/ALLEGRO_FS_ENTRY"><span class="a">ALLEGRO_FS_ENTRY</span></a><span class="k3">*</span> file<span class="k2">;</span>
<span class="number"> 14</span>           <span class="k1">while</span><span class="k2">(</span>file <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_read_directory"><span class="a">al_read_directory</span></a><span class="k2">(</span>dir<span class="k2">)</span><span class="k2">)</span>
<span class="number"> 15</span>           <span class="k2">{</span>
<span class="number"> 16</span>               <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"%s\n"</span>, <a href="http://www.allegro.cc/manual/al_get_fs_entry_name"><span class="a">al_get_fs_entry_name</span></a><span class="k2">(</span>file<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 17</span>               <a href="http://www.allegro.cc/manual/al_destroy_fs_entry"><span class="a">al_destroy_fs_entry</span></a><span class="k2">(</span>file<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 18</span>           <span class="k2">}</span>
<span class="number"> 19</span>       <span class="k2">}</span>
<span class="number"> 20</span>       <a href="http://www.allegro.cc/manual/al_destroy_fs_entry"><span class="a">al_destroy_fs_entry</span></a><span class="k2">(</span>dir<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 21</span>       <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 22</span>   <span class="k2">}</span>
<span class="number"> 23</span><span class="k2">}</span>
</div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 16 Mar 2011 19:30:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks guys....just got it right before you posted. <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" /> I think the function names are a little confusing in this regard... Maybe should post an example of this in the wiki. I start feeling a little better and get some free time, I might do it. Thanks again. <img src="http://www.allegro.cc/forums/smileys/kiss.gif" alt=":-*" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Wed, 16 Mar 2011 19:33:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hmm. I wonder how you tell if an FS_ENTRY is a file or a directory. Also, it&#39;d be nice to be able to get the ALLEGRO_PATH from an FS_ENTRY without using the potentially unsafe al_get_fs_entry_name.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 16 Mar 2011 19:36:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/606721/908208#target">SiegeLord</a> said:</div><div class="quote"><p>Hmm. I wonder how you tell if an FS_ENTRY is a file or a directory.</p></div></div><p>

<span class="source-code"><a href="http://www.allegro.cc/manual/al_get_fs_entry_mode"><span class="a">al_get_fs_entry_mode</span></a><span class="k2">(</span>entry<span class="k2">)</span> <span class="k3">&amp;</span> ALLEGRO_FILEMODE_ISDIR</span></p><p>Does nobody ever look at the examples? There&#39;s an ex_dir which re-imlpements the ls command with the A5 API...</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>Also, it&#39;d be nice to be able to get the ALLEGRO_PATH from an FS_ENTRY without using the potentially unsafe al_get_fs_entry_name.</p></div></div><p>

Even better would be if you could get an ALLEGRO_FILE since if filenames are not encoded as utf8 both a string as well as ALLEGRO_PATH would break it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Wed, 16 Mar 2011 19:45:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/606721/908211#target">Elias</a> said:</div><div class="quote"><p>
Does nobody ever look at the examples?
</p></div></div><p>
I blame the binary distribution <img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 16 Mar 2011 19:49:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/606721/908211#target">Elias</a> said:</div><div class="quote"><p>Even better would be if you could get an ALLEGRO_FILE since if filenames are not encoded as utf8 both a string as well as ALLEGRO_PATH would break it.</p></div></div><p>That all used to just work with the original API <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /> I think the old way was thought to be too confusing. Ah well.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 16 Mar 2011 19:51:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/606721/908212#target">SiegeLord</a> said:</div><div class="quote"><p>I blame the binary distribution <img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" />.
</p></div></div><p>

Maybe we should package binaries of the examples as well? It would increase the size quite a bit though (especially with static linking).</p><p>But it would also make it easier to test out A5, just downloading the library with nothing to run is a bit boring <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Wed, 16 Mar 2011 20:00:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Maybe provide a separate &quot;example/demo&quot; binary that contains the example sources and binaries.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 16 Mar 2011 20:05:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>They&#39;d need the example source files to learn from, and if their binary distribution is OK, a simple makefile with compiler options should suffice.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Wed, 16 Mar 2011 20:10:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>that would be great, I always thought why there weren&#39;t examples at the binaries if it&#39;s what almost everybody uses (at least in windows)...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Wed, 16 Mar 2011 20:17:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/606721/908214#target">Elias</a> said:</div><div class="quote"><p>Maybe we should package binaries of the examples as well? It would increase the size quite a bit though (especially with static linking).</p></div></div><p>
I don&#39;t think there&#39;s much point in a binary distribution of the examples, to be honest. Now, a <i>test</i> program I could see the use of (I know most of the examples are really test programs in disguise).</p><p>However, it would make sense (to me) to include the example sources in the binary package (for Windows anyway, for Linux it should probably be a separate package).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 16 Mar 2011 20:35:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Don&#39;t know, when I tried for example Ogre3D I really liked how I could try their examples before I had to commit and actually install and compile stuff.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Wed, 16 Mar 2011 22:09:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The examples are provided in binary form here on A.cc.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Thu, 17 Mar 2011 00:43:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There&#39;s also usually working examples linked to each online manual page via forum discussions. Sitting across the Internet, you cannot force someone to click and read.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Thu, 17 Mar 2011 01:11:31 +0000</pubDate>
	</item>
</rss>
