<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>A5 Make Path Absolute</title>
		<link>http://www.allegro.cc/forums/view/608723</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 03 Nov 2011 05:59:12 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In Allegro 5, al_make_path_canonical does not seem to convert relative paths to absolute, whereas Allegro 4&#39;s canonicalize_filename did (as I recall).</p><p>I concede that the newer approach makes perfect sense as a relative path is arguably more simple but don&#39;t worry about all that.</p><p>Anyway, I could missing something simple so...</p><p>Does Allegro 5 have a simple &quot;1 liner&quot; method to make a path absolute, or do I have to code my way around it by getting the CWD manually and appending the path?</p><p>al_make_path_absolute_where_possible()?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (James Bunting)</author>
		<pubDate>Thu, 03 Nov 2011 02:41:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Here ya go :
</p><div class="source-code snippet"><div class="inner"><pre>string RelativeToAbsolute<span class="k2">(</span>string relative<span class="k2">)</span> <span class="k2">{</span>
   <span class="k1">return</span> string<span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_current_directory"><span class="a">al_get_current_directory</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span> <span class="k3">+</span> ALLEGRO_NATIVE_PATH_SEP <span class="k3">+</span> relative<span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 03 Nov 2011 02:50:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>First create a path for the current working directory:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">char</span> <span class="k3">*</span>tmp <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_current_directory"><span class="a">al_get_current_directory</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
ALLEGRO_PATH <span class="k3">*</span>cwd <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_path_for_directory"><span class="a">al_create_path_for_directory</span></a><span class="k2">(</span>tmp<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_free"><span class="a">al_free</span></a><span class="k2">(</span>tmp<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Then whenever you want an absolute path:
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_rebase_path"><span class="a">al_rebase_path</span></a><span class="k2">(</span>cwd, path<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

So it&#39;s a one liner if you first create a global path object for the current working directory. (Be sure to free it later.)</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/608723/935973#target">Edgar Reynaldo</a> said:</div><div class="quote"><p> Here ya go :
</p></div></div><p>Leaks memory due to the call to <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_current_directory"><span class="a">al_get_current_directory</span></a><span class="k2">(</span><span class="k2">)</span></span>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Thu, 03 Nov 2011 02:50:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hm, I thought it existed, but it looks like it slipped my mind. All it would likely do is just append cwd and the path, which can be done easily enough.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Thu, 03 Nov 2011 02:51:00 +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/608723/935974#target">Matthew Leverton</a> said:</div><div class="quote"><p>
Leaks memory due to the call to al_get_current_directory(). 
</p></div></div><p>
Whoops.</p><p>Fixed :
</p><div class="source-code snippet"><div class="inner"><pre>string RelativeToAbsolute<span class="k2">(</span>string relative<span class="k2">)</span> <span class="k2">{</span>
   <span class="k1">char</span><span class="k3">*</span> cwd <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_current_directory"><span class="a">al_get_current_directory</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
   string path <span class="k3">=</span> string<span class="k2">(</span>cwd<span class="k2">)</span> <span class="k3">+</span> ALLEGRO_NATIVE_PATH_SEP <span class="k3">+</span> relative<span class="k2">;</span>
   <a href="http://www.allegro.cc/manual/al_free"><span class="a">al_free</span></a><span class="k2">(</span>cwd<span class="k2">)</span><span class="k2">;</span>
   <span class="k1">return</span> path<span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 03 Nov 2011 02:55:43 +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/608723/935975#target">Thomas Fjellstrom</a> said:</div><div class="quote"><p> Hm, I thought it existed, but it looks like it slipped my mind
</p></div></div><p>It&#39;s kind of a specialty function that I&#39;m not sure should exist in Allegro. That is, creating an absolute path from the current working directory is two discrete steps.</p><p>It might be nice to have something like: <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_standard_path"><span class="a">al_get_standard_path</span></a><span class="k2">(</span>ALLEGRO_CURRENT_PATH<span class="k2">)</span></span>, but even that is just a convenience wrapper around the code I wrote above.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Thu, 03 Nov 2011 02:57:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for the help people.</p><p>For the record I am working on porting a file picker dialog I originally wrote for AllegroGL under Allegro 4.  I could not find a file dialog in 5 (apart from the native one which crashes in full screen and would require a mode switch anyway).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (James Bunting)</author>
		<pubDate>Thu, 03 Nov 2011 05:29:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If it crashes in full screen, then cheat : <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_new_display_flags"><span class="a">al_set_new_display_flags</span></a><span class="k2">(</span>ALLEGRO_FULLSCREEN_WINDOW<span class="k2">)</span><span class="k2">;</span></span>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 03 Nov 2011 05:31:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sounds promising, I will look into that thanks.</p><p>Shot of work in progress picker here BTW<br /><a href="http://www.jbserver.com/temp/picker.jpg">http://www.jbserver.com/temp/picker.jpg</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (James Bunting)</author>
		<pubDate>Thu, 03 Nov 2011 05:44:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>RE: pic<br />Looks pretty good. I think the scrollbar handles should be shrunk to fit inside the scrollbar area though, just by a pixel though. They almost look oversized right now.</p><p>If you&#39;re feeling ambitious, you might want to implement a folder tree.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 03 Nov 2011 05:59:12 +0000</pubDate>
	</item>
</rss>
