<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to File_Manipulation</title><link>https://sourceforge.net/p/hpg-projects/wiki/File_Manipulation/</link><description>Recent changes to File_Manipulation</description><atom:link href="https://sourceforge.net/p/hpg-projects/wiki/File_Manipulation/feed" rel="self"/><language>en</language><lastBuildDate>Fri, 20 Jan 2023 12:15:44 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/hpg-projects/wiki/File_Manipulation/feed" rel="self" type="application/rss+xml"/><item><title>File_Manipulation modified by Hugh Greene</title><link>https://sourceforge.net/p/hpg-projects/wiki/File_Manipulation/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;The nice thing about emulating such a file manipulation library as Game&lt;br/&gt;
Maker's is that the method of identifying a file is an integer, like&lt;br/&gt;
everything else, which remains compliant with a 2-component variant data&lt;br/&gt;
type. Though many may prefer to keep track of the FILE pointer&lt;br/&gt;
themselves, this is a convenient method for those who don't wish to&lt;br/&gt;
concern themselves with such.&lt;/p&gt;
&lt;h2 id="classes"&gt;Classes&lt;/h2&gt;
&lt;p&gt;Achieving a unified storage class between text, binary, and ini file&lt;br/&gt;
manipulation is relatively simple due to the range of functions offered&lt;br/&gt;
by the original Game Maker library. The &lt;a class="" href="#Binary_File_Functions" title="wikilink"&gt;binary file&lt;br/&gt;
functions&lt;/a&gt; offered a method to clear&lt;br/&gt;
the file and start anew; this requires reopening the file by its&lt;br/&gt;
original name, which would need to be stored in that case. Text files&lt;br/&gt;
likewise require a string to store the last line read. Neither category&lt;br/&gt;
needs use of both.&lt;/p&gt;
&lt;p&gt;That being the case, text and binary files are stored in a single&lt;br/&gt;
structure containing a &lt;code&gt;FILE*&lt;/code&gt; member and a string member.&lt;/p&gt;
&lt;h2 id="text-file-functions"&gt;Text File Functions&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Opens a text file for reading.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Opens a text file for writing.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Opens a text file for writing, but begins at the end of the file if&lt;br/&gt;
    it exists.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="differences"&gt;Differences&lt;/h4&gt;
&lt;p&gt;For efficiency concerns, a slight modification was made to text file&lt;br/&gt;
behavior. While Game Maker does its reading in&lt;br/&gt;
file_text_read_string/real, and just sets variables in&lt;br/&gt;
file_text_readln and file_text_open, ENIGMA reads the first line in&lt;br/&gt;
the file as soon as a call to open is made. This saves a check in calls&lt;br/&gt;
to file_text_read_ string()/_real() down the road, but causes&lt;br/&gt;
file_text_open_read() itself to take slightly longer. Typical use of&lt;br/&gt;
these functions will introduce no visible difference, save minute&lt;br/&gt;
speedup.&lt;/p&gt;
&lt;h2 id="binary-file-functions"&gt;Binary File Functions&lt;/h2&gt;
&lt;p&gt;opens the file &lt;em&gt;fname&lt;/em&gt; as a binary file with the given &lt;em&gt;mode&lt;/em&gt;, which is&lt;br/&gt;
an integer from the table below.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Read&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;Opens the file for reading.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Write&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Opens the file for writing.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Both&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Opens the file with read and write permissions.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="cc-file-functions"&gt;C/C++ File Functions&lt;/h2&gt;
&lt;p&gt;Again, since &lt;a class="" href="/p/hpg-projects/wiki/EDL/" title="wikilink"&gt;EDL&lt;/a&gt; is extended upon C++, you still have&lt;br/&gt;
access to the lower level file functions if you desire to access those.&lt;br/&gt;
These include the C stdio functions, fopen, fread, fwrite, and fclose,&lt;br/&gt;
in which case you would need to keep the FILE pointer, rather than just&lt;br/&gt;
the variant integer.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Hugh Greene</dc:creator><pubDate>Fri, 20 Jan 2023 12:15:44 -0000</pubDate><guid>https://sourceforge.net9899bcdd21ea4ed4c55fcedb3c1ede93ef81fcdb</guid></item></channel></rss>