<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<script type="text/javascript" language="JavaScript">
//<![CDATA[
function reDo() {
if (innerWidth != origWidth || innerHeight != origHeight)
location.reload();
}
if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
origWidth = innerWidth;
origHeight = innerHeight;
onresize = reDo;
}
onerror = null;
//]]>
</script>
<style type="text/css">/*<![CDATA[*/
< !-- div.WebHelpPopupMenu {
position: absolute;
left: 0px;
top: 0px;
z-index: 4;
visibility: hidden;
}
p.WebHelpNavBar {
text-align: right;
}
-->
/*]]>*/</style>
<script type="text/javascript">//<![CDATA[
gRootRelPath = "../../..";
gCommonRootRelPath = "../../..";
gTopicId = "9.2.16";
//]]></script>
<script type="text/javascript" src="../../../template/scripts/rh.min.js"></script>
<script type="text/javascript" src="../../../template/scripts/common.min.js"></script>
<script type="text/javascript" src="../../../template/scripts/topic.min.js"></script>
<script type="text/javascript" src="../../../template/scripts/topicwidgets.min.js"></script>
<script type="text/javascript" src="../../../whxdata/projectsettings.js"></script>
<link rel="stylesheet" type="text/css" href="../../../template/styles/topic.min.css"/>
<link rel="stylesheet" type="text/css" href="../../../template/Charcoal_Grey/topicheader.css"/>
<meta name="topic-status" content="Draft"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>File Handling</title>
<meta name="generator" content="Adobe RoboHelp 2019"/>
<link rel="stylesheet" href="../../../assets/css/default.css" type="text/css"/>
<meta name="rh-authors" content="Mark Alexander"/>
<meta name="topic-comment" content="Reference section for the File Handling functions"/>
<meta name="rh-index-keywords" content=""/>
<meta name="search-keywords" content="File Handling"/>
</head>
<body>
<div class="topic-header rh-hide" id="rh-topic-header" onclick="rh._.goToFullLayout()">
<div class="logo">
</div>
<div class="nav">
<div class="title" title="File Handling">
<span>File Handling</span>
</div>
<div class="gotohome" title="Click here to see this page in full context">
<span>Click here to see this page in full context</span>
</div>
</div>
</div>
<div class="topic-header-shadow rh-hide" id="rh-topic-header-shadow"></div>
<!--<div class="body-scroll" style="top: 150px;">-->
<h1>File Handling</h1>
<p>At some point while creating your game it will be necessary to store information externally and be able to retrieve this information. For example, you may wish to store login details, or hi-scores, or maybe the progression of the player through your
levels. Whatever the reason, you will need to know how to use the different file functions that are available to you when working with GameMaker Studio 2.</p>
<p>It is very important to realise that GameMaker Studio 2 is <b>Sandboxed </b>by default, meaning that there are a number of limits and minor complications when using the file system functions that are available, and it is worth noting too that
the file system will work slightly differently depending on the platform you are targeting. For more information this, please see the following section:</p>
<ul class="colour">
<li><a href="../../../Additional_Information/The_File_System.htm">The File System</a></li>
</ul>
<p>You can turn off sandboxing on the desktop targets (Windows, macOS and Ubuntu (Linux)) from the Game Options for the chosen platform, meaning that you can then save and load from anywhere, within the limits of the OS permissions.</p>
<p>If you have been granted permission by Steam to use their dedicated API with your game, you will find that there is also a new set of file functions available to you. These are explained in the <a href="../Steam/Steam.htm">Steam API</a> section of this
manual.</p>
<p>Finally, you should also note that there are some distinct differences between certain target platforms which would be taken into account when using the file functions. These are:<b></b></p>
<ul class="colour">
<li><b>iOS</b>: On iOS, if you are loading an included file from a folder, ie: with a path something like "<tt>Backgrounds/background1.png</tt>", you do NOT need to include the folder as part of the path and simply supplying the file name is
sufficient. On all other platforms you must supply the folder(s) as part of the path to the file.<b></b></li>
<li><b>macOS and Ubuntu (Linux)</b>: On the macOS and Ubunutu, filenames and paths are case sensitive on these platforms, and so to prevent any potential issues, GameMaker Studio 2 will automatically make all names/paths use lower case by default.<b></b></li>
<li><b>HTML5</b>: On HTML5, saving and loading to and from <b>local storage</b> will work as explained within the different function pages, however if you are loading a file from a server, you <b>must only use the function <a href="../Buffers/buffer_load_async.htm"><tt>buffer_load_async()</tt></a></b> as loading synchronously has been deprecated on most browsers and will eventually be obsoleted.</li>
</ul>
<p>Information on the different file functions can be found in the following pages:</p>
<p> </p>
<ul class="colour">
<li><a href="File_System/File_System.htm">File System</a></li>
<li><a href="Ini_Files/Ini_Files.htm">Ini Files</a></li>
<li><a href="Text_Files/Text_Files.htm">Text Files</a></li>
<li><a href="Binary_Files/Binary_Files.htm">Binary Files</a></li>
<li><a href="File_Directories/File_Directories.htm">File Directories</a></li>
</ul>
<p> </p>
<p>GameMaker Studio 2 also includes a number of functions for <a class="tooltip" title="Encoding transforms data into another format using a scheme that is publicly available so that it can easily be reversed. This is not the same as encryption, as it does not require a key to decode it. Encoding is generally used to either change the data into a format for eaiser use by a different system (like sending data to a server), or for making data unreadable to the human eye.">encoding</a> and <a class="tooltip" title="Hashing is the method of creating a string or value that relates to a single source - usually a file - and ONLY that source. For example., in GameMaker you can generate a hash for a save file, then, before accessing it later, generate another hash for it and check the original hash and the new hash to determine if the file has been tampered with.">hashing</a> files and data, which you can find here:</p>
<p> </p>
<ul class="colour">
<li><a href="Encoding_And_Hashing/Encoding_And_Hashing.htm">Encoding And Hashing</a></li>
</ul>
<p> </p>
<p>Also note that there are some basic file functions for saving games available from the following pages (be aware that these functions are designed for beginners to get a basic save system up and running as quickly as possible, but for more complex projects,
you should create your own save system using the functions listed in the sections above):</p>
<p> </p>
<ul class="colour">
<li><a href="../General_Game_Control/game_load.htm">game_load</a></li>
<li><a href="../General_Game_Control/game_load_buffer.htm">game_load_buffer</a></li>
<li><a href="../General_Game_Control/game_save.htm">game_save</a></li>
<li><a href="../General_Game_Control/game_save_buffer.htm">game_save_buffer</a></li>
</ul>
<p> </p>
<p>Finally you can find more advanced <a href="../Buffers/Buffers.htm">buffer</a> functions that can be used for loading and saving data on the following pages:</p>
<p> </p>
<ul class="colour">
<li><a href="../Buffers/buffer_save.htm">buffer_save</a></li>
<li><a href="../Buffers/buffer_save_ext.htm">buffer_save_ext</a></li>
<li><a href="../Buffers/buffer_save_async.htm">buffer_save_async</a></li>
<li><a href="../Buffers/buffer_load.htm">buffer_load</a></li>
<li><a href="../Buffers/buffer_load_ext.htm">buffer_load_ext</a></li>
<li><a href="../Buffers/buffer_load_async.htm">buffer_load_async</a></li>
<li><a href="../Buffers/buffer_load_partial.htm">buffer_load_partial</a></li>
<li><a href="../Buffers/buffer_async_group_begin.htm">buffer_async_group_begin</a></li>
<li><a href="../Buffers/buffer_async_group_option.htm">buffer_async_group_option</a></li>
<li><a href="../Buffers/buffer_async_group_end.htm">buffer_async_group_end</a></li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<div class="footer">
<div class="buttons">
<div class="clear">
<div style="float:left">Back: <a href="../GML_Reference.htm">GML Reference</a></div>
<div style="float:right">Next: <a href="../Buffers/Buffers.htm">Buffers</a></div>
</div>
</div>
<h5>© Copyright YoYo Games Ltd. 2020 All Rights Reserved</h5>
</div>
<!-- KEYWORDS
File Handling
-->
<!-- TAGS
file_functions
-->
</body></html>