<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Game cannot write to its installation folder</title>
		<link>http://www.allegro.cc/forums/view/613656</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 17 Dec 2013 08:14:28 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello,</p><p>I just recently finished up a game in A5, used the nullsoft installer to create a deployment package, went over to my wife&#39;s laptop (running Windows XP Professional), installed ok, ran ok up until the point it need to save data to a file (I&#39;m using the Boost library for serialization):</p><p>Code 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>std::ofstream output_file<span class="k2">(</span><span class="s">"Data/db_joystickconfig.dat"</span>, std::ios::binary<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 2</span>boost::archive::binary_oarchive oa<span class="k2">(</span>output_file<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 3</span>oa <span class="k3">&lt;</span><span class="k3">&lt;</span> joystickMapping<span class="k2">;</span>
<span class="number"> 4</span>output_file.close<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
</div></div><p>

&quot;Data&quot; is a folder off the installation root (ie: c:\Program Files\My Game\).<br />&quot;joystickMapping&quot; is just a struct defined elsewhere.</p><p>Anyone have experience with this? It runs fine if I launch the shortcut as Administrator, so I know it&#39;s permission related, just not sure how to &quot;force&quot; it or give it permission to write.</p><p>Thanks,<br />Rich
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Werwolf696)</author>
		<pubDate>Tue, 17 Dec 2013 06:31:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s modern OSs for you. you can&#39;t write to system directories. You need to use the user&#39;s or shared user&#39;s data directory. in A5, you can use the <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> function for that. Otherwise you basically need operating specific apis to get that information.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 17 Dec 2013 06:44:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sounds like you should be saving to the <span class="source-code">ALLEGRO_USER_SETTINGS_PATH</span> location.</p><ol><li><p><span class="source-code"><a href="http://www.allegro.cc/manual/al_set_org_name"><span class="a">al_set_org_name</span></a><span class="k2">(</span><span class="k2">)</span></span>
</p></li><li><p><span class="source-code"><a href="http://www.allegro.cc/manual/al_set_app_name"><span class="a">al_set_app_name</span></a><span class="k2">(</span><span class="k2">)</span></span>
</p></li><li><p><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_USER_SETTINGS_PATH<span class="k2">)</span></span>
</p></li><li><p><span class="source-code"><a href="http://www.allegro.cc/manual/al_make_directory"><span class="a">al_make_directory</span></a><span class="k2">(</span><span class="k2">)</span></span> if does not exist (no guarantee that it does)
</p></li><li><p>Create a path based off of that directory + db_joystickconfig.dat via <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_path_filename"><span class="a">al_set_path_filename</span></a><span class="k2">(</span><span class="k2">)</span></span>
</p></li></ol></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Tue, 17 Dec 2013 06:58:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>And if you want to write actual data (and not config), you use <span class="source-code">ALLEGRO_USER_DATA_PATH</span>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 17 Dec 2013 07:00:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Awesome, thanks guys. My first Windows game, not used to all this security stuff. I appreciate your help.</p><p>Rich
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Werwolf696)</author>
		<pubDate>Tue, 17 Dec 2013 07:06:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There&#39;s a special folder for saved games on windows vista and newer versions of windows, the allegro API doesn&#39;t support anything to find this folder though. Might be useful to have a function that returns a special path to the saved games folder if one is available.</p><p>Anyway, some games do save to the program files folder directly. It can be done by requesting admin privileges.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (l j)</author>
		<pubDate>Tue, 17 Dec 2013 07:35:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
</p><div class="quote_container"><div class="title">taron said:</div><div class="quote"><p>Anyway, some games do save to the program files folder directly. It can be done by requesting admin privileges.</p></div></div><p>

Taron, how does one request admin privileges within the game?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Werwolf696)</author>
		<pubDate>Tue, 17 Dec 2013 07:53:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You don&#39;t want to. The user will get a big scary UAC popup.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 17 Dec 2013 08:14:28 +0000</pubDate>
	</item>
</rss>
