<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>al_fread problems on Windows</title>
		<link>http://www.allegro.cc/forums/view/615644</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 11 Aug 2015 07:54:01 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Using 5.0.10 on Windows, I&#39;m unable to correctly use al_fread.</p><p>I have a struct, 102 bytes in size, which I save directly to a file to store the game configuration. Under all operating systems the write works correctly. Using a hex editor I can verify the data is stored correctly, and is the right size.</p><p>When loading it, all 102 bytes are fine except on Windows, where invariably after 20 bytes al_feof returns true. I&#39;ve tried loading this in every way I can think of, including abuse of al_fgetc, manually looping with al_fread16le, and loading with al_fread pointing to the struct address I want to fill. Always it loads twenty bytes, and does not set an error flag.</p><p>Screenshots of the problem are attached to this post. In the terminal I am rendering the read struct contents, and when it fails my sanity check it writes a new copy with the correct data visible below it. The hex editor is the data shown correctly on disk, and the relevant code is included as well. </p><p>Does anyone know what&#39;s going on here?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michael Moffitt)</author>
		<pubDate>Mon, 10 Aug 2015 05:20:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you are reading/writing binary data, try <span class="source-code"><a href="http://www.allegro.cc/manual/al_fopen"><span class="a">al_fopen</span></a><span class="k2">(</span><span class="s">"file"</span>, <span class="s">"rb"</span><span class="k2">)</span></span> and <span class="source-code"><a href="http://www.allegro.cc/manual/al_fopen"><span class="a">al_fopen</span></a><span class="k2">(</span><span class="s">"file"</span>, <span class="s">"wb"</span><span class="k2">)</span></span>. Not sure if it is the source of your problem, but I had similar issues in the past which were solved by doing this.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Mon, 10 Aug 2015 06:50:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There it is, I did forget to specify binary reading/writing. Thanks for the tip. It works great now.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michael Moffitt)</author>
		<pubDate>Tue, 11 Aug 2015 07:54:01 +0000</pubDate>
	</item>
</rss>
