<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>PHYSFS_addToSearchPath</title>
		<link>http://www.allegro.cc/forums/view/613087</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 10 Aug 2013 20:22:02 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In the documentation there is this sentence:</p><p>&quot;Add an archive or directory to the search path.&quot;</p><p>And my question is... Can I mount a directory that is inside an archive? Say i have an archive called <i>archive.dat</i> in which there is a directory named <i>folder</i>. Now I want to search for certain files first in <i>folder</i> and if they are not found, then in the root of the archive. I tried something like this:</p><p><span class="source-code">PHYSFS_addToSearchPath<span class="k2">(</span><span class="s">"archive.dat/folder"</span>, <span class="n">0</span><span class="k2">)</span> <span class="c">//0 so that it is prepended</span></span></p><p>... but it fails. Is there a way to do it?</p><p>Thanks...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (APrince)</author>
		<pubDate>Wed, 07 Aug 2013 19:18:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Not a very good answer, but I <u>think</u> you can &quot;cd&quot; in the archive. Check the manual.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Wed, 07 Aug 2013 22:44:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What manual? There&#39;s the <a href="http://icculus.org/physfs/docs/html/physfs_8h.html">documentation</a> but I don&#39;t know of anything else...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (APrince)</author>
		<pubDate>Thu, 08 Aug 2013 02:50:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If I&#39;m not mistaken you want <span class="source-code"><a href="http://www.allegro.cc/manual/al_change_directory"><span class="a">al_change_directory</span></a></span> after <span class="source-code">al_set_physfs_file_system</span>. You&#39;ll have to try it yourself though unless someone else knows for sure.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Thu, 08 Aug 2013 03:04:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, you can use <span class="source-code"><a href="http://www.allegro.cc/manual/al_change_directory"><span class="a">al_change_directory</span></a></span> with the PhysFS add-on.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Thu, 08 Aug 2013 04:41:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I tried by it does not help me much. The problem is with the use case I described. There may be (typically are) more files with the same name. Now I need to make sure that first, they are going to be searched in the subdirectory. Now I don&#39;t know how this whole al_change_directory() thing works internally, but what would happen if I called the al_change_directory(&quot;folder&quot;) and there were more directories called &quot;folder&quot; present in the path?</p><p>And did you mean al_set_physfs_file_interface() rather than  al_set_physfs_file_system()?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (APrince)</author>
		<pubDate>Fri, 09 Aug 2013 13:03:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>After a quick read trough the PHYSFS documentation it seems that &quot;mounting a directory&quot; is referring to the real directory on your drive not the one in the archive.</p><p>You cannot do:<br /><span class="source-code">PHYSFS_addToSearchPath<span class="k2">(</span><span class="s">"archive.dat/my_folder"</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></span></p><p>You can do only:<br /><span class="source-code">PHYSFS_addToSearchPath<span class="k2">(</span><span class="s">"archive.dat"</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></span><br /><span class="source-code">PHYSFS_addToSearchPath<span class="k2">(</span><span class="s">"$HOME/my_folder"</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></span><br /><span class="source-code">PHYSFS_addToSearchPath<span class="k2">(</span><span class="s">"c:/BrokenOS/my_folder"</span>, <span class="n">0</span><span class="k2">)</span></span></p><p>And if you don&#39;t need backward compatibility with PHYSFS 1.0 you should use:<br /><span class="source-code"><span class="k1">int</span> PHYSFS_mount<span class="k2">(</span> <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>newDir, <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>mountPoint, <span class="k1">int</span> appendToPath <span class="k2">)</span><span class="k2">;</span></span></p><p>For the searching part, i guess you could do something like this:
</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><a href="http://www.allegro.cc/manual/ALLEGRO_FILE"><span class="a">ALLEGRO_FILE</span></a> <span class="k3">*</span>f<span class="k2">;</span>
<span class="number">  2</span>
<span class="number">  3</span>f <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_fopen"><span class="a">al_fopen</span></a><span class="k2">(</span> <span class="s">"$ARCHIVE_ROOT/search_here_fist/file_to_find.dat"</span>, <span class="s">"rb"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  4</span><span class="k1">if</span><span class="k2">(</span> <span class="k3">!</span>f <span class="k2">)</span>
<span class="number">  5</span> <span class="k2">{</span>
<span class="number">  6</span> f <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_fopen"><span class="a">al_fopen</span></a><span class="k2">(</span> <span class="s">"$ARCHIVE_ROOT/file_to_find.dat"</span>, <span class="s">"rb"</span> <span class="k2">)</span><span class="k2">;</span>
<span class="number">  7</span> <span class="k2">}</span>
<span class="number">  8</span>
<span class="number">  9</span><span class="k1">if</span><span class="k2">(</span> f <span class="k2">)</span>
<span class="number"> 10</span> <span class="k2">{</span>
<span class="number"> 11</span> <span class="c">// Do something with the file...</span>
<span class="number"> 12</span> <a href="http://www.allegro.cc/manual/al_fclose"><span class="a">al_fclose</span></a><span class="k2">(</span> f <span class="k2">)</span><span class="k2">;</span>
<span class="number"> 13</span> <span class="k2">}</span>
<span class="number"> 14</span><span class="k1">else</span>
<span class="number"> 15</span> <span class="k2">{</span>
<span class="number"> 16</span> <span class="c">// Could not find the file...</span>
<span class="number"> 17</span> <span class="k2">}</span>
</div></div><p>

Correct me if i am wrong on something.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Izual)</author>
		<pubDate>Fri, 09 Aug 2013 14:33:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I &quot;think&quot; allegro&#39;s al_change_directory emulates a chdir inside archives. Id have to check the code to make sure. but I think it works, even inside archives.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sat, 10 Aug 2013 00:14:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I trust Todd when he says it does.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Sat, 10 Aug 2013 03:24:51 +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/613087/988544#target">APrince</a> said:</div><div class="quote"><p>There may be (typically are) more files with the same name.</p></div></div><p>
PhysFS will load the &quot;newest&quot; file of any given name based on when search paths were added.</p><p>If you have <tt>archive.zip/sounds/swipe.wav</tt> and <tt>mypath/sounds/swipe.wav</tt>, PhysFS will open whichever was added to the search path most recently. If you use <span class="source-code"><a href="http://www.allegro.cc/manual/al_change_directory"><span class="a">al_change_directory</span></a><span class="k2">(</span><span class="k2">)</span></span> to go into the <tt>sounds</tt> directory, the rule still applies.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>Now I don&#39;t know how this whole al_change_directory() thing works internally, but what would happen if I called the al_change_directory(&quot;folder&quot;) and there were more directories called &quot;folder&quot; present in the path?</p></div></div><p>

You just have to remember how PhysFS works. If there are two search paths with folders named <tt>sounds</tt>, you can open files from either of those directories as if they are in the same directory.</p><p>In the above example, if there was a file called <tt>touch.wav</tt> in <tt>mypath/sounds</tt> but not in <tt>archive.zip/sounds</tt>, calling <span class="source-code"><a href="http://www.allegro.cc/manual/al_load_sample"><span class="a">al_load_sample</span></a><span class="k2">(</span><span class="s">"sounds/touch.wav"</span><span class="k2">)</span></span> will load the file <tt>mypath/sounds/touch.wav</tt>. If <tt>touch.wav</tt> was in both, it would load whichever is &quot;newer&quot; as previously described.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Sat, 10 Aug 2013 20:22:02 +0000</pubDate>
	</item>
</rss>
