<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>open directories with special characters</title>
		<link>http://www.allegro.cc/forums/view/617652</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 10 Dec 2018 14:54:28 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello !. I have a problem opening directories with special cards. The only thing that works for me is directories with no special characters. Thank you.</p><p>           .......................</p><p>dialogo1 = al_create_native_file_dialog(&quot;&quot;, &quot;&quot;, &quot;&quot;, ALLEGRO_FILECHOOSER_FOLDER);<br />al_show_native_file_dialog(ventana, dialogo1);<br />DIRECTORIO = al_create_fs_entry(al_get_native_file_dialog_path(dialogo1, 0));<br />if (!(al_open_directory(DIRECTORIO))) {<br />		al_show_native_message_box(ventana, &quot;Mensaje&quot;, &quot;Error&quot;, &quot;IMPOSIBLE LEER DIRECTORIO ORIGEN&quot;, NULL, ALLEGRO_MESSAGEBOX_ERROR);  	}
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (alex glez)</author>
		<pubDate>Thu, 06 Dec 2018 18:58:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can use &lt;code&gt;code goes here...&lt;/code&gt; tags for code please.</p><p>Can you produce a simple example program that does this? What do you mean by special characters? Where? In the source code? Or on your OS? Or?</p><p>Please be as specific as possible and help us reproduce this. What compiler and what version of allegro are you using?</p><p><b>EDIT</b></p><p>Do you mean specifically unicode characters? Non ascii? What is your OS and what language are you using?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 06 Dec 2018 22:19:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I use the Spanish language. Windows 10 system. Visual studio.<br />The version of allegro is 5.<br />With the names of folders with special characters<br /> ( canción , フォルダの例 ...  ) <br />the previous program fails.<br />It only reads folders with ascii characters from 0 to 127.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (alex glez)</author>
		<pubDate>Fri, 07 Dec 2018 02:26:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre>dialogo1 <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_native_file_dialog"><span class="a">al_create_native_file_dialog</span></a><span class="k2">(</span><span class="s">""</span>, <span class="s">""</span>, <span class="s">""</span>, ALLEGRO_FILECHOOSER_FOLDER<span class="k2">)</span><span class="k2">;</span>

<a href="http://www.allegro.cc/manual/al_show_native_file_dialog"><span class="a">al_show_native_file_dialog</span></a><span class="k2">(</span>ventana, dialogo1<span class="k2">)</span><span class="k2">;</span>

DIRECTORIO <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><a href="http://www.allegro.cc/manual/al_get_native_file_dialog_path"><span class="a">al_get_native_file_dialog_path</span></a><span class="k2">(</span>dialogo1, <span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>

<span class="k1">if</span> <span class="k2">(</span><span class="k3">!</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>DIRECTORIO<span class="k2">)</span><span class="k2">)</span><span class="k2">)</span> 
  <span class="k2">{</span>
  <a href="http://www.allegro.cc/manual/al_show_native_message_box"><span class="a">al_show_native_message_box</span></a><span class="k2">(</span>ventana, <span class="s">"Mensaje"</span>, <span class="s">"Error"</span>, 
  <span class="s">"IMPOSIBLE LEER DIRECTORIO ORIGEN"</span>, NULL, ALLEGRO_MESSAGEBOX_ERROR<span class="k2">)</span><span class="k2">;</span> 
  <span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Fri, 07 Dec 2018 05:40:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m new to this end of the API, but from the looks of it calling <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_native_file_dialog_path"><span class="a">al_get_native_file_dialog_path</span></a></span> when the user hasn&#39;t selected a file will just return NULL. <b>Unfortunately, you&#39;re not <a href="https://wiki.allegro.cc/index.php?title=Return_value">checking return values</a>.</b> To help you understand where your program goes wrong you should be checking return values and printing error messages when something unexpected happens (like if <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_native_file_dialog_path"><span class="a">al_get_native_file_dialog_path</span></a></span> returns <span class="source-code">NULL</span>, since your program is currently assuming that won&#39;t happen). Don&#39;t pass the result of functions that can possibly fail to other functions. Store the result, check it, and then pass it on. It will save you a lot of trouble.</p><p>I don&#39;t know who created this API, but it seems pretty insane. Apparently you need to query <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_native_file_dialog_count"><span class="a">al_get_native_file_dialog_count</span></a></span> until it returns a value <span class="source-code"><span class="k3">&gt;</span> <span class="n">0</span></span> and that indicates that you can then get the path(s) from the dialog. This seems very racy and insane. You&#39;d think with Allegro&#39;s event system that the dialog would signal selected paths with an event, but I digress... I guess that means to get the path that you need to do something like:</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="c">// Create dialog..</span>
<span class="number">  2</span><span class="c">// Show dialog...</span>
<span class="number">  3</span>
<span class="number">  4</span><span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span> path <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number">  5</span>
<span class="number">  6</span><span class="k1">while</span> <span class="k2">(</span><span class="n">1</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number">  7</span>    path <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_native_file_dialog_path"><span class="a">al_get_native_file_dialog_path</span></a><span class="k2">(</span>dialogo1<span class="k2">)</span><span class="k2">;</span>
<span class="number">  8</span>
<span class="number">  9</span>    <span class="k1">if</span> <span class="k2">(</span>path<span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 10</span>        <span class="k1">break</span><span class="k2">;</span>
<span class="number"> 11</span>    <span class="k2">}</span>
<span class="number"> 12</span>
<span class="number"> 13</span>    <a href="http://www.allegro.cc/manual/al_rest"><span class="a">al_rest</span></a><span class="k2">(</span><span class="n">0</span>.<span class="n">2</span><span class="k2">)</span><span class="k2">;</span> <span class="c">// h4x: Yield some CPU because this API suxx0rs.</span>
<span class="number"> 14</span><span class="k2">}</span>
<span class="number"> 15</span>
<span class="number"> 16</span><span class="c">// Yay, if you ever escaped from that loop you should now have a path selected.</span>
<span class="number"> 17</span>
<span class="number"> 18</span><a href="http://www.allegro.cc/manual/al_destroy_native_file_dialog"><span class="a">al_destroy_native_file_dialog</span></a><span class="k2">(</span>dialogo1<span class="k2">)</span><span class="k2">;</span>
</div></div><p>

It&#39;s bizarre that there isn&#39;t an event when the user actually clicks &quot;OK&quot; or something in the dialog. Assuming that is a thing. I don&#39;t know if I&#39;ve ever seen the dialog that Allegro produces.</p><p>A timeout probably doesn&#39;t make sense for a file selection dialog... I cannot imagine how you&#39;re supposed to make a user-friendly program from this. Am I missing something crucial to this API, or is it just not really meant to be used?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Fri, 07 Dec 2018 11:24:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>al_show_native_file_dialog blocks until it returns. The underlying dialog probably doesn&#39;t support Unicode.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 07 Dec 2018 15:28:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Odd. Tried it on Linux (debian/gnome) and it seemed to be OK with unicode filenames but there was no way to choose a folder - if I selected one and pressed Open it would always just open the folder and show its contents.
</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;allegro5/allegro.h&gt;</span>
<span class="number">  2</span><span class="p">#include &lt;allegro5/allegro_native_dialog.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>, <span class="k1">char</span> <span class="k3">*</span><span class="k2">[</span><span class="k2">]</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number">  5</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">  6</span>  al_init_native_dialog_addon<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  7</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>ventana <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number">  8</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_FILECHOOSER"><span class="a">ALLEGRO_FILECHOOSER</span></a> <span class="k3">*</span>dialogo1 <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_native_file_dialog"><span class="a">al_create_native_file_dialog</span></a><span class="k2">(</span>
<span class="number">  9</span>      NULL, <span class="s">"Title"</span>, <span class="s">"*"</span>, ALLEGRO_FILECHOOSER_FOLDER<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 10</span>
<span class="number"> 11</span>  <span class="k1">bool</span> ans <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_show_native_file_dialog"><span class="a">al_show_native_file_dialog</span></a><span class="k2">(</span>ventana, dialogo1<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 12</span>  <span class="k1">if</span> <span class="k2">(</span>ans <span class="k3">&amp;</span><span class="k3">&amp;</span> <a href="http://www.allegro.cc/manual/al_get_native_file_dialog_count"><span class="a">al_get_native_file_dialog_count</span></a><span class="k2">(</span>dialogo1<span class="k2">)</span> <span class="k3">&gt;</span> <span class="n">0</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 13</span>    <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>cc <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_native_file_dialog_path"><span class="a">al_get_native_file_dialog_path</span></a><span class="k2">(</span>dialogo1, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 14</span>    <a href="http://www.allegro.cc/manual/ALLEGRO_FS_ENTRY"><span class="a">ALLEGRO_FS_ENTRY</span></a> <span class="k3">*</span>DIRECTORIO <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>cc<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 15</span>
<span class="number"> 16</span>    <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</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>DIRECTORIO<span class="k2">)</span><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_show_native_message_box"><span class="a">al_show_native_message_box</span></a><span class="k2">(</span>ventana, <span class="s">"Mensaje"</span>, <span class="s">"Error"</span>,
<span class="number"> 18</span>                                 <span class="s">"IMPOSIBLE LEER DIRECTORIO ORIGEN"</span>, NULL,
<span class="number"> 19</span>                                 ALLEGRO_MESSAGEBOX_ERROR<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 20</span>    <span class="k2">}</span> <span class="k1">else</span> <span class="k2">{</span>
<span class="number"> 21</span>      <a href="http://www.allegro.cc/manual/al_show_native_message_box"><span class="a">al_show_native_message_box</span></a><span class="k2">(</span>ventana, <span class="s">"Mensaje"</span>, <span class="s">"Info"</span>,
<span class="number"> 22</span>                                 <span class="s">"YES YOU ARE A CAPTAIN"</span>, NULL, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 23</span>    <span class="k2">}</span>
<span class="number"> 24</span>  <span class="k2">}</span>
<span class="number"> 25</span>  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 26</span><span class="k2">}</span>
</div></div><p>

<b>Edit:</b> Actually <a href="https://github.com/liballeg/allegro5/commit/9781f35cd0f6a6086eda822b3d9f62c6a13d8350#diff-e0471653ea675abc5952e5f5a7743632">it&#39;s been fixed</a> - Debian installs 5.2.2 but when I built Allegro myself (5.2.5) it worked.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Fri, 07 Dec 2018 16:54:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Peter, it&#39;s still broken on Windows.</p><p>I had to fix a null pointer crash for your code to work (in allegro) and then it ran okay. But I tried making a directory called &#39;ù&#39; and you can&#39;t select it with the dialog.</p><p>This is with Allegro 5.2.X from GIT.</p><p>The null pointer crash is in win_dialog.c on line</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"> 71</span><span class="k1">static</span> <span class="k1">bool</span> select_folder<span class="k2">(</span>ALLEGRO_DISPLAY_WIN <span class="k3">*</span>win_display,
<span class="number"> 72</span>   ALLEGRO_NATIVE_DIALOG <span class="k3">*</span>fd<span class="k2">)</span>
<span class="number"> 73</span><span class="k2">{</span>
<span class="number"> 74</span>   BROWSEINFO folderinfo<span class="k2">;</span>
<span class="number"> 75</span>   LPCITEMIDLIST pidl<span class="k2">;</span>
<span class="number"> 76</span>   <span class="k1">char</span> buf<span class="k2">[</span>MAX_PATH<span class="k2">]</span> <span class="k3">=</span> <span class="s">""</span><span class="k2">;</span>
<span class="number"> 77</span>   <span class="k1">char</span> dbuf<span class="k2">[</span>MAX_PATH<span class="k2">]</span> <span class="k3">=</span> <span class="s">""</span><span class="k2">;</span>
<span class="number"> 78</span>
<div class="highlight"><span class="number"> 79</span>   folderinfo.hwndOwner <span class="k3">=</span> win_display-&gt;window<span class="k2">;</span></div><span class="number"> 80</span>   folderinfo.pidlRoot <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number"> 81</span>   folderinfo.pszDisplayName <span class="k3">=</span> dbuf<span class="k2">;</span>
<span class="number"> 82</span>   folderinfo.lpszTitle <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_cstr"><span class="a">al_cstr</span></a><span class="k2">(</span>fd-&gt;title<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 83</span>   folderinfo.ulFlags <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 84</span>   folderinfo.lpfn <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number"> 85</span>
<span class="number"> 86</span>   pidl <span class="k3">=</span> SHBrowseForFolder<span class="k2">(</span><span class="k3">&amp;</span>folderinfo<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 87</span>   <span class="k1">if</span> <span class="k2">(</span>pidl<span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 88</span>      SHGetPathFromIDList<span class="k2">(</span>pidl, buf<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 89</span>      fd-&gt;fc_path_count <span class="k3">=</span> <span class="n">1</span><span class="k2">;</span>
<span class="number"> 90</span>      fd-&gt;fc_paths <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_malloc"><span class="a">al_malloc</span></a><span class="k2">(</span><span class="k1">sizeof</span><span class="k2">(</span><span class="k1">void</span> <span class="k3">*</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 91</span>      fd-&gt;fc_paths<span class="k2">[</span><span class="n">0</span><span class="k2">]</span> <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_path"><span class="a">al_create_path</span></a><span class="k2">(</span>buf<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 92</span>      <span class="k1">return</span> <span class="k1">true</span><span class="k2">;</span>
<span class="number"> 93</span>   <span class="k2">}</span>
<span class="number"> 94</span>   <span class="k1">return</span> <span class="k1">false</span><span class="k2">;</span>
<span class="number"> 95</span><span class="k2">}</span>
</div></div><p>

<a href="https://liballeg.org/a5docs/trunk/native_dialog.html#al_show_native_file_dialog">al_show_native_file_dialog</a> specifically says you can pass null for the display, but select_folder doesn&#39;t handle it. Assigning hwndOwner to NULL works fine to fix it though.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 07 Dec 2018 21:00:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I interpret then that you can not open folders in this way that contain characters that are not ascii (from 0 to 127)?</p><p>With directory names (ascii from 0 to 127) it works perfect ..
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (alex glez)</author>
		<pubDate>Sat, 08 Dec 2018 01:42:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>OK,<br />when I said &quot;it&#39;s been fixed&quot; I meant not being able to select directories on Linux.<br />The problem with Windows seems to be that it was written specifically to use the ANSI API. (As I&#39;m sure you know) a lot of Windows functions have two variants, one ending in A for ANSI the other ending in W for wide characters, i.e. unicode. (<a href="https://docs.microsoft.com/en-us/windows/desktop/api/commdlg/nf-commdlg-getopenfilenamea">example</a>)<br />Edgar, your null pointer crash is also a bug, well spotted - the <a href="https://www.allegro.cc/manual/5/al_show_native_file_dialog">docs</a> say it&#39;s OK to pass NULL for the display.<br />Pete
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Sat, 08 Dec 2018 04:12:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I understand, thanks to everyone for the help. My knowledge is very limited, anyway I have 95% completed the program (some retouching is missing) and although I would like to solve the problem, it is not vital for its correct functioning. Maybe for later ...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (alex glez)</author>
		<pubDate>Sat, 08 Dec 2018 17:20:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So guys how are we going to fix it?</p><p>please tell me technicalities, I want to work on it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Doctor Cop)</author>
		<pubDate>Sat, 08 Dec 2018 20:56:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There are several problems. One, as Peter mentioned, the ascii version of windows dialog functions are being used, instead of the wide character version. This means no unicode support.</p><p>Second, the old dialogs have been superseded by the Common Item dialog starting with Windows Vista, so there are new Open and Save dialogs that should be used instead.</p><p><a href="https://msdn.microsoft.com/en-us/library/Bb776913%28v=VS.85%29.aspx">Common Item Dialog</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sat, 08 Dec 2018 23:13:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>1. Fork <a href="https://github.com/liballeg/allegro5">https://github.com/liballeg/allegro5</a><br />2. Fix<br />3. Test<br />4. Make a pull request</p><p>and you&#39;re done!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Mon, 10 Dec 2018 14:54:28 +0000</pubDate>
	</item>
</rss>
