|
@@ -3,12 +3,12 @@
|
|
.. DO NOT EDIT THIS FILE!!!
|
|
.. DO NOT EDIT THIS FILE!!!
|
|
.. Generated automatically from Godot engine sources.
|
|
.. Generated automatically from Godot engine sources.
|
|
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
|
|
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
|
|
-.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/File.xml.
|
|
|
|
|
|
+.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/FileAccess.xml.
|
|
|
|
|
|
-.. _class_File:
|
|
|
|
|
|
+.. _class_FileAccess:
|
|
|
|
|
|
-File
|
|
|
|
-====
|
|
|
|
|
|
+FileAccess
|
|
|
|
+==========
|
|
|
|
|
|
**Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
|
**Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
|
|
|
|
|
@@ -27,34 +27,26 @@ Here's a sample on how to write and read from a file:
|
|
.. code-tab:: gdscript
|
|
.. code-tab:: gdscript
|
|
|
|
|
|
func save(content):
|
|
func save(content):
|
|
- var file = File.new()
|
|
|
|
- file.open("user://save_game.dat", File.WRITE)
|
|
|
|
|
|
+ var file = FileAccess.open("user://save_game.dat", FileAccess.WRITE)
|
|
file.store_string(content)
|
|
file.store_string(content)
|
|
- file.close()
|
|
|
|
|
|
|
|
func load():
|
|
func load():
|
|
- var file = File.new()
|
|
|
|
- file.open("user://save_game.dat", File.READ)
|
|
|
|
|
|
+ var file = FileAccess.open("user://save_game.dat", FileAccess.READ)
|
|
var content = file.get_as_text()
|
|
var content = file.get_as_text()
|
|
- file.close()
|
|
|
|
return content
|
|
return content
|
|
|
|
|
|
.. code-tab:: csharp
|
|
.. code-tab:: csharp
|
|
|
|
|
|
public void Save(string content)
|
|
public void Save(string content)
|
|
{
|
|
{
|
|
- var file = new File();
|
|
|
|
- file.Open("user://save_game.dat", File.ModeFlags.Write);
|
|
|
|
|
|
+ using var file = FileAccess.Open("user://save_game.dat", FileAccess.ModeFlags.Write);
|
|
file.StoreString(content);
|
|
file.StoreString(content);
|
|
- file.Close();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public string Load()
|
|
public string Load()
|
|
{
|
|
{
|
|
- var file = new File();
|
|
|
|
- file.Open("user://save_game.dat", File.ModeFlags.Read);
|
|
|
|
|
|
+ using var file = FileAccess.Open("user://save_game.dat", FileAccess.ModeFlags.Read);
|
|
string content = file.GetAsText();
|
|
string content = file.GetAsText();
|
|
- file.Close();
|
|
|
|
return content;
|
|
return content;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -62,9 +54,26 @@ Here's a sample on how to write and read from a file:
|
|
|
|
|
|
In the example above, the file will be saved in the user data folder as specified in the :doc:`Data paths <../tutorials/io/data_paths>` documentation.
|
|
In the example above, the file will be saved in the user data folder as specified in the :doc:`Data paths <../tutorials/io/data_paths>` documentation.
|
|
|
|
|
|
-\ **Note:** To access project resources once exported, it is recommended to use :ref:`ResourceLoader<class_ResourceLoader>` instead of the ``File`` API, as some files are converted to engine-specific formats and their original source files might not be present in the exported PCK package.
|
|
|
|
|
|
+There is no method to close a file in order to free it from use. Instead, ``FileAccess`` will close when it's freed, which happens when it goes out of scope or when it gets assigned with ``null``. In C# the reference must be disposed after we are done using it, this can be done with the ``using`` statement or calling the ``Dispose`` method directly.
|
|
|
|
|
|
-\ **Note:** Files are automatically closed only if the process exits "normally" (such as by clicking the window manager's close button or pressing **Alt + F4**). If you stop the project execution by pressing **F8** while the project is running, the file won't be closed as the game process will be killed. You can work around this by calling :ref:`flush<class_File_method_flush>` at regular intervals.
|
|
|
|
|
|
+
|
|
|
|
+.. tabs::
|
|
|
|
+
|
|
|
|
+ .. code-tab:: gdscript
|
|
|
|
+
|
|
|
|
+ var file = FileAccess.open("res://something") # File is opened and locked for use.
|
|
|
|
+ file = null # File is closed.
|
|
|
|
+
|
|
|
|
+ .. code-tab:: csharp
|
|
|
|
+
|
|
|
|
+ using var file = FileAccess.Open("res://something"); // File is opened and locked for use.
|
|
|
|
+ // The using statement calls Dispose when going out of scope.
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+\ **Note:** To access project resources once exported, it is recommended to use :ref:`ResourceLoader<class_ResourceLoader>` instead of the ``FileAccess`` API, as some files are converted to engine-specific formats and their original source files might not be present in the exported PCK package.
|
|
|
|
+
|
|
|
|
+\ **Note:** Files are automatically closed only if the process exits "normally" (such as by clicking the window manager's close button or pressing **Alt + F4**). If you stop the project execution by pressing **F8** while the project is running, the file won't be closed as the game process will be killed. You can work around this by calling :ref:`flush<class_FileAccess_method_flush>` at regular intervals.
|
|
|
|
|
|
Tutorials
|
|
Tutorials
|
|
---------
|
|
---------
|
|
@@ -76,117 +85,117 @@ Tutorials
|
|
Properties
|
|
Properties
|
|
----------
|
|
----------
|
|
|
|
|
|
-+-------------------------+---------------------------------------------------+-----------+
|
|
|
|
-| :ref:`bool<class_bool>` | :ref:`big_endian<class_File_property_big_endian>` | ``false`` |
|
|
|
|
-+-------------------------+---------------------------------------------------+-----------+
|
|
|
|
|
|
++-------------------------+---------------------------------------------------------+
|
|
|
|
+| :ref:`bool<class_bool>` | :ref:`big_endian<class_FileAccess_property_big_endian>` |
|
|
|
|
++-------------------------+---------------------------------------------------------+
|
|
|
|
|
|
Methods
|
|
Methods
|
|
-------
|
|
-------
|
|
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`close<class_File_method_close>` **(** **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`bool<class_bool>` | :ref:`eof_reached<class_File_method_eof_reached>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`bool<class_bool>` | :ref:`file_exists<class_File_method_file_exists>` **(** :ref:`String<class_String>` path **)** |static| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`flush<class_File_method_flush>` **(** **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`int<class_int>` | :ref:`get_16<class_File_method_get_16>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`int<class_int>` | :ref:`get_32<class_File_method_get_32>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`int<class_int>` | :ref:`get_64<class_File_method_get_64>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`int<class_int>` | :ref:`get_8<class_File_method_get_8>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`String<class_String>` | :ref:`get_as_text<class_File_method_get_as_text>` **(** :ref:`bool<class_bool>` skip_cr=false **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`get_buffer<class_File_method_get_buffer>` **(** :ref:`int<class_int>` length **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_csv_line<class_File_method_get_csv_line>` **(** :ref:`String<class_String>` delim="," **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`float<class_float>` | :ref:`get_double<class_File_method_get_double>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`get_error<class_File_method_get_error>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`float<class_float>` | :ref:`get_float<class_File_method_get_float>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`int<class_int>` | :ref:`get_length<class_File_method_get_length>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`String<class_String>` | :ref:`get_line<class_File_method_get_line>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`String<class_String>` | :ref:`get_md5<class_File_method_get_md5>` **(** :ref:`String<class_String>` path **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`int<class_int>` | :ref:`get_modified_time<class_File_method_get_modified_time>` **(** :ref:`String<class_String>` file **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`String<class_String>` | :ref:`get_pascal_string<class_File_method_get_pascal_string>` **(** **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`String<class_String>` | :ref:`get_path<class_File_method_get_path>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`String<class_String>` | :ref:`get_path_absolute<class_File_method_get_path_absolute>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`int<class_int>` | :ref:`get_position<class_File_method_get_position>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`float<class_float>` | :ref:`get_real<class_File_method_get_real>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`String<class_String>` | :ref:`get_sha256<class_File_method_get_sha256>` **(** :ref:`String<class_String>` path **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`Variant<class_Variant>` | :ref:`get_var<class_File_method_get_var>` **(** :ref:`bool<class_bool>` allow_objects=false **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`bool<class_bool>` | :ref:`is_open<class_File_method_is_open>` **(** **)** |const| |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open<class_File_method_open>` **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_File_ModeFlags>` flags **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open_compressed<class_File_method_open_compressed>` **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_File_ModeFlags>` mode_flags, :ref:`CompressionMode<enum_File_CompressionMode>` compression_mode=0 **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open_encrypted<class_File_method_open_encrypted>` **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_File_ModeFlags>` mode_flags, :ref:`PackedByteArray<class_PackedByteArray>` key **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open_encrypted_with_pass<class_File_method_open_encrypted_with_pass>` **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_File_ModeFlags>` mode_flags, :ref:`String<class_String>` pass **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`seek<class_File_method_seek>` **(** :ref:`int<class_int>` position **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`seek_end<class_File_method_seek_end>` **(** :ref:`int<class_int>` position=0 **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_16<class_File_method_store_16>` **(** :ref:`int<class_int>` value **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_32<class_File_method_store_32>` **(** :ref:`int<class_int>` value **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_64<class_File_method_store_64>` **(** :ref:`int<class_int>` value **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_8<class_File_method_store_8>` **(** :ref:`int<class_int>` value **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_buffer<class_File_method_store_buffer>` **(** :ref:`PackedByteArray<class_PackedByteArray>` buffer **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_csv_line<class_File_method_store_csv_line>` **(** :ref:`PackedStringArray<class_PackedStringArray>` values, :ref:`String<class_String>` delim="," **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_double<class_File_method_store_double>` **(** :ref:`float<class_float>` value **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_float<class_File_method_store_float>` **(** :ref:`float<class_float>` value **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_line<class_File_method_store_line>` **(** :ref:`String<class_String>` line **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_pascal_string<class_File_method_store_pascal_string>` **(** :ref:`String<class_String>` string **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_real<class_File_method_store_real>` **(** :ref:`float<class_float>` value **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_string<class_File_method_store_string>` **(** :ref:`String<class_String>` string **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-| void | :ref:`store_var<class_File_method_store_var>` **(** :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` full_objects=false **)** |
|
|
|
|
-+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`bool<class_bool>` | :ref:`eof_reached<class_FileAccess_method_eof_reached>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`bool<class_bool>` | :ref:`file_exists<class_FileAccess_method_file_exists>` **(** :ref:`String<class_String>` path **)** |static| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`flush<class_FileAccess_method_flush>` **(** **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`int<class_int>` | :ref:`get_16<class_FileAccess_method_get_16>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`int<class_int>` | :ref:`get_32<class_FileAccess_method_get_32>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`int<class_int>` | :ref:`get_64<class_FileAccess_method_get_64>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`int<class_int>` | :ref:`get_8<class_FileAccess_method_get_8>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`String<class_String>` | :ref:`get_as_text<class_FileAccess_method_get_as_text>` **(** :ref:`bool<class_bool>` skip_cr=false **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`get_buffer<class_FileAccess_method_get_buffer>` **(** :ref:`int<class_int>` length **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_csv_line<class_FileAccess_method_get_csv_line>` **(** :ref:`String<class_String>` delim="," **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`float<class_float>` | :ref:`get_double<class_FileAccess_method_get_double>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`get_error<class_FileAccess_method_get_error>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`float<class_float>` | :ref:`get_float<class_FileAccess_method_get_float>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`int<class_int>` | :ref:`get_length<class_FileAccess_method_get_length>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`String<class_String>` | :ref:`get_line<class_FileAccess_method_get_line>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`String<class_String>` | :ref:`get_md5<class_FileAccess_method_get_md5>` **(** :ref:`String<class_String>` path **)** |static| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`int<class_int>` | :ref:`get_modified_time<class_FileAccess_method_get_modified_time>` **(** :ref:`String<class_String>` file **)** |static| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`get_open_error<class_FileAccess_method_get_open_error>` **(** **)** |static| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`String<class_String>` | :ref:`get_pascal_string<class_FileAccess_method_get_pascal_string>` **(** **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`String<class_String>` | :ref:`get_path<class_FileAccess_method_get_path>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`String<class_String>` | :ref:`get_path_absolute<class_FileAccess_method_get_path_absolute>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`int<class_int>` | :ref:`get_position<class_FileAccess_method_get_position>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`float<class_float>` | :ref:`get_real<class_FileAccess_method_get_real>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`String<class_String>` | :ref:`get_sha256<class_FileAccess_method_get_sha256>` **(** :ref:`String<class_String>` path **)** |static| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`Variant<class_Variant>` | :ref:`get_var<class_FileAccess_method_get_var>` **(** :ref:`bool<class_bool>` allow_objects=false **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`bool<class_bool>` | :ref:`is_open<class_FileAccess_method_is_open>` **(** **)** |const| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`FileAccess<class_FileAccess>` | :ref:`open<class_FileAccess_method_open>` **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` flags **)** |static| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`FileAccess<class_FileAccess>` | :ref:`open_compressed<class_FileAccess_method_open_compressed>` **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` mode_flags, :ref:`CompressionMode<enum_FileAccess_CompressionMode>` compression_mode=0 **)** |static| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`FileAccess<class_FileAccess>` | :ref:`open_encrypted<class_FileAccess_method_open_encrypted>` **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` mode_flags, :ref:`PackedByteArray<class_PackedByteArray>` key **)** |static| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| :ref:`FileAccess<class_FileAccess>` | :ref:`open_encrypted_with_pass<class_FileAccess_method_open_encrypted_with_pass>` **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` mode_flags, :ref:`String<class_String>` pass **)** |static| |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`seek<class_FileAccess_method_seek>` **(** :ref:`int<class_int>` position **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`seek_end<class_FileAccess_method_seek_end>` **(** :ref:`int<class_int>` position=0 **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_16<class_FileAccess_method_store_16>` **(** :ref:`int<class_int>` value **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_32<class_FileAccess_method_store_32>` **(** :ref:`int<class_int>` value **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_64<class_FileAccess_method_store_64>` **(** :ref:`int<class_int>` value **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_8<class_FileAccess_method_store_8>` **(** :ref:`int<class_int>` value **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_buffer<class_FileAccess_method_store_buffer>` **(** :ref:`PackedByteArray<class_PackedByteArray>` buffer **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_csv_line<class_FileAccess_method_store_csv_line>` **(** :ref:`PackedStringArray<class_PackedStringArray>` values, :ref:`String<class_String>` delim="," **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_double<class_FileAccess_method_store_double>` **(** :ref:`float<class_float>` value **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_float<class_FileAccess_method_store_float>` **(** :ref:`float<class_float>` value **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_line<class_FileAccess_method_store_line>` **(** :ref:`String<class_String>` line **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_pascal_string<class_FileAccess_method_store_pascal_string>` **(** :ref:`String<class_String>` string **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_real<class_FileAccess_method_store_real>` **(** :ref:`float<class_float>` value **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_string<class_FileAccess_method_store_string>` **(** :ref:`String<class_String>` string **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
+| void | :ref:`store_var<class_FileAccess_method_store_var>` **(** :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` full_objects=false **)** |
|
|
|
|
++---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
|
|
Enumerations
|
|
Enumerations
|
|
------------
|
|
------------
|
|
|
|
|
|
-.. _enum_File_ModeFlags:
|
|
|
|
|
|
+.. _enum_FileAccess_ModeFlags:
|
|
|
|
|
|
-.. _class_File_constant_READ:
|
|
|
|
|
|
+.. _class_FileAccess_constant_READ:
|
|
|
|
|
|
-.. _class_File_constant_WRITE:
|
|
|
|
|
|
+.. _class_FileAccess_constant_WRITE:
|
|
|
|
|
|
-.. _class_File_constant_READ_WRITE:
|
|
|
|
|
|
+.. _class_FileAccess_constant_READ_WRITE:
|
|
|
|
|
|
-.. _class_File_constant_WRITE_READ:
|
|
|
|
|
|
+.. _class_FileAccess_constant_WRITE_READ:
|
|
|
|
|
|
enum **ModeFlags**:
|
|
enum **ModeFlags**:
|
|
|
|
|
|
@@ -200,15 +209,15 @@ enum **ModeFlags**:
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _enum_File_CompressionMode:
|
|
|
|
|
|
+.. _enum_FileAccess_CompressionMode:
|
|
|
|
|
|
-.. _class_File_constant_COMPRESSION_FASTLZ:
|
|
|
|
|
|
+.. _class_FileAccess_constant_COMPRESSION_FASTLZ:
|
|
|
|
|
|
-.. _class_File_constant_COMPRESSION_DEFLATE:
|
|
|
|
|
|
+.. _class_FileAccess_constant_COMPRESSION_DEFLATE:
|
|
|
|
|
|
-.. _class_File_constant_COMPRESSION_ZSTD:
|
|
|
|
|
|
+.. _class_FileAccess_constant_COMPRESSION_ZSTD:
|
|
|
|
|
|
-.. _class_File_constant_COMPRESSION_GZIP:
|
|
|
|
|
|
+.. _class_FileAccess_constant_COMPRESSION_GZIP:
|
|
|
|
|
|
enum **CompressionMode**:
|
|
enum **CompressionMode**:
|
|
|
|
|
|
@@ -223,36 +232,26 @@ enum **CompressionMode**:
|
|
Property Descriptions
|
|
Property Descriptions
|
|
---------------------
|
|
---------------------
|
|
|
|
|
|
-.. _class_File_property_big_endian:
|
|
|
|
|
|
+.. _class_FileAccess_property_big_endian:
|
|
|
|
|
|
- :ref:`bool<class_bool>` **big_endian**
|
|
- :ref:`bool<class_bool>` **big_endian**
|
|
|
|
|
|
-+-----------+-----------------------+
|
|
|
|
-| *Default* | ``false`` |
|
|
|
|
-+-----------+-----------------------+
|
|
|
|
-| *Setter* | set_big_endian(value) |
|
|
|
|
-+-----------+-----------------------+
|
|
|
|
-| *Getter* | is_big_endian() |
|
|
|
|
-+-----------+-----------------------+
|
|
|
|
|
|
++----------+-----------------------+
|
|
|
|
+| *Setter* | set_big_endian(value) |
|
|
|
|
++----------+-----------------------+
|
|
|
|
+| *Getter* | is_big_endian() |
|
|
|
|
++----------+-----------------------+
|
|
|
|
|
|
If ``true``, the file is read with big-endian `endianness <https://en.wikipedia.org/wiki/Endianness>`__. If ``false``, the file is read with little-endian endianness. If in doubt, leave this to ``false`` as most files are written with little-endian endianness.
|
|
If ``true``, the file is read with big-endian `endianness <https://en.wikipedia.org/wiki/Endianness>`__. If ``false``, the file is read with little-endian endianness. If in doubt, leave this to ``false`` as most files are written with little-endian endianness.
|
|
|
|
|
|
-\ **Note:** :ref:`big_endian<class_File_property_big_endian>` is only about the file format, not the CPU type. The CPU endianness doesn't affect the default endianness for files written.
|
|
|
|
|
|
+\ **Note:** :ref:`big_endian<class_FileAccess_property_big_endian>` is only about the file format, not the CPU type. The CPU endianness doesn't affect the default endianness for files written.
|
|
|
|
|
|
-\ **Note:** This is always reset to ``false`` whenever you open the file. Therefore, you must set :ref:`big_endian<class_File_property_big_endian>` *after* opening the file, not before.
|
|
|
|
|
|
+\ **Note:** This is always reset to ``false`` whenever you open the file. Therefore, you must set :ref:`big_endian<class_FileAccess_property_big_endian>` *after* opening the file, not before.
|
|
|
|
|
|
Method Descriptions
|
|
Method Descriptions
|
|
-------------------
|
|
-------------------
|
|
|
|
|
|
-.. _class_File_method_close:
|
|
|
|
-
|
|
|
|
-- void **close** **(** **)**
|
|
|
|
-
|
|
|
|
-Closes the currently opened file and prevents subsequent read/write operations. Use :ref:`flush<class_File_method_flush>` to persist the data to disk without closing the file.
|
|
|
|
-
|
|
|
|
-----
|
|
|
|
-
|
|
|
|
-.. _class_File_method_eof_reached:
|
|
|
|
|
|
+.. _class_FileAccess_method_eof_reached:
|
|
|
|
|
|
- :ref:`bool<class_bool>` **eof_reached** **(** **)** |const|
|
|
- :ref:`bool<class_bool>` **eof_reached** **(** **)** |const|
|
|
|
|
|
|
@@ -279,7 +278,7 @@ Returns ``true`` if the file cursor has already read past the end of the file.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_file_exists:
|
|
|
|
|
|
+.. _class_FileAccess_method_file_exists:
|
|
|
|
|
|
- :ref:`bool<class_bool>` **file_exists** **(** :ref:`String<class_String>` path **)** |static|
|
|
- :ref:`bool<class_bool>` **file_exists** **(** :ref:`String<class_String>` path **)** |static|
|
|
|
|
|
|
@@ -287,51 +286,53 @@ Returns ``true`` if the file exists in the given path.
|
|
|
|
|
|
\ **Note:** Many resources types are imported (e.g. textures or sound files), and their source asset will not be included in the exported game, as only the imported version is used. See :ref:`ResourceLoader.exists<class_ResourceLoader_method_exists>` for an alternative approach that takes resource remapping into account.
|
|
\ **Note:** Many resources types are imported (e.g. textures or sound files), and their source asset will not be included in the exported game, as only the imported version is used. See :ref:`ResourceLoader.exists<class_ResourceLoader_method_exists>` for an alternative approach that takes resource remapping into account.
|
|
|
|
|
|
|
|
+For a non-static, relative equivalent, use :ref:`DirAccess.file_exists<class_DirAccess_method_file_exists>`.
|
|
|
|
+
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_flush:
|
|
|
|
|
|
+.. _class_FileAccess_method_flush:
|
|
|
|
|
|
- void **flush** **(** **)**
|
|
- void **flush** **(** **)**
|
|
|
|
|
|
-Writes the file's buffer to disk. Flushing is automatically performed when the file is closed. This means you don't need to call :ref:`flush<class_File_method_flush>` manually before closing a file using :ref:`close<class_File_method_close>`. Still, calling :ref:`flush<class_File_method_flush>` can be used to ensure the data is safe even if the project crashes instead of being closed gracefully.
|
|
|
|
|
|
+Writes the file's buffer to disk. Flushing is automatically performed when the file is closed. This means you don't need to call :ref:`flush<class_FileAccess_method_flush>` manually before closing a file. Still, calling :ref:`flush<class_FileAccess_method_flush>` can be used to ensure the data is safe even if the project crashes instead of being closed gracefully.
|
|
|
|
|
|
-\ **Note:** Only call :ref:`flush<class_File_method_flush>` when you actually need it. Otherwise, it will decrease performance due to constant disk writes.
|
|
|
|
|
|
+\ **Note:** Only call :ref:`flush<class_FileAccess_method_flush>` when you actually need it. Otherwise, it will decrease performance due to constant disk writes.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_16:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_16:
|
|
|
|
|
|
- :ref:`int<class_int>` **get_16** **(** **)** |const|
|
|
- :ref:`int<class_int>` **get_16** **(** **)** |const|
|
|
|
|
|
|
-Returns the next 16 bits from the file as an integer. See :ref:`store_16<class_File_method_store_16>` for details on what values can be stored and retrieved this way.
|
|
|
|
|
|
+Returns the next 16 bits from the file as an integer. See :ref:`store_16<class_FileAccess_method_store_16>` for details on what values can be stored and retrieved this way.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_32:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_32:
|
|
|
|
|
|
- :ref:`int<class_int>` **get_32** **(** **)** |const|
|
|
- :ref:`int<class_int>` **get_32** **(** **)** |const|
|
|
|
|
|
|
-Returns the next 32 bits from the file as an integer. See :ref:`store_32<class_File_method_store_32>` for details on what values can be stored and retrieved this way.
|
|
|
|
|
|
+Returns the next 32 bits from the file as an integer. See :ref:`store_32<class_FileAccess_method_store_32>` for details on what values can be stored and retrieved this way.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_64:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_64:
|
|
|
|
|
|
- :ref:`int<class_int>` **get_64** **(** **)** |const|
|
|
- :ref:`int<class_int>` **get_64** **(** **)** |const|
|
|
|
|
|
|
-Returns the next 64 bits from the file as an integer. See :ref:`store_64<class_File_method_store_64>` for details on what values can be stored and retrieved this way.
|
|
|
|
|
|
+Returns the next 64 bits from the file as an integer. See :ref:`store_64<class_FileAccess_method_store_64>` for details on what values can be stored and retrieved this way.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_8:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_8:
|
|
|
|
|
|
- :ref:`int<class_int>` **get_8** **(** **)** |const|
|
|
- :ref:`int<class_int>` **get_8** **(** **)** |const|
|
|
|
|
|
|
-Returns the next 8 bits from the file as an integer. See :ref:`store_8<class_File_method_store_8>` for details on what values can be stored and retrieved this way.
|
|
|
|
|
|
+Returns the next 8 bits from the file as an integer. See :ref:`store_8<class_FileAccess_method_store_8>` for details on what values can be stored and retrieved this way.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_as_text:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_as_text:
|
|
|
|
|
|
- :ref:`String<class_String>` **get_as_text** **(** :ref:`bool<class_bool>` skip_cr=false **)** |const|
|
|
- :ref:`String<class_String>` **get_as_text** **(** :ref:`bool<class_bool>` skip_cr=false **)** |const|
|
|
|
|
|
|
@@ -341,7 +342,7 @@ If ``skip_cr`` is ``true``, carriage return characters (``\r``, CR) will be igno
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_buffer:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_buffer:
|
|
|
|
|
|
- :ref:`PackedByteArray<class_PackedByteArray>` **get_buffer** **(** :ref:`int<class_int>` length **)** |const|
|
|
- :ref:`PackedByteArray<class_PackedByteArray>` **get_buffer** **(** :ref:`int<class_int>` length **)** |const|
|
|
|
|
|
|
@@ -349,7 +350,7 @@ Returns next ``length`` bytes of the file as a :ref:`PackedByteArray<class_Packe
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_csv_line:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_csv_line:
|
|
|
|
|
|
- :ref:`PackedStringArray<class_PackedStringArray>` **get_csv_line** **(** :ref:`String<class_String>` delim="," **)** |const|
|
|
- :ref:`PackedStringArray<class_PackedStringArray>` **get_csv_line** **(** :ref:`String<class_String>` delim="," **)** |const|
|
|
|
|
|
|
@@ -369,7 +370,7 @@ Note how the second line can omit the enclosing quotes as it does not include th
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_double:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_double:
|
|
|
|
|
|
- :ref:`float<class_float>` **get_double** **(** **)** |const|
|
|
- :ref:`float<class_float>` **get_double** **(** **)** |const|
|
|
|
|
|
|
@@ -377,7 +378,7 @@ Returns the next 64 bits from the file as a floating-point number.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_error:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_error:
|
|
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **get_error** **(** **)** |const|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **get_error** **(** **)** |const|
|
|
|
|
|
|
@@ -385,7 +386,7 @@ Returns the last error that happened when trying to perform operations. Compare
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_float:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_float:
|
|
|
|
|
|
- :ref:`float<class_float>` **get_float** **(** **)** |const|
|
|
- :ref:`float<class_float>` **get_float** **(** **)** |const|
|
|
|
|
|
|
@@ -393,7 +394,7 @@ Returns the next 32 bits from the file as a floating-point number.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_length:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_length:
|
|
|
|
|
|
- :ref:`int<class_int>` **get_length** **(** **)** |const|
|
|
- :ref:`int<class_int>` **get_length** **(** **)** |const|
|
|
|
|
|
|
@@ -401,7 +402,7 @@ Returns the size of the file in bytes.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_line:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_line:
|
|
|
|
|
|
- :ref:`String<class_String>` **get_line** **(** **)** |const|
|
|
- :ref:`String<class_String>` **get_line** **(** **)** |const|
|
|
|
|
|
|
@@ -411,23 +412,31 @@ Text is interpreted as being UTF-8 encoded.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_md5:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_md5:
|
|
|
|
|
|
-- :ref:`String<class_String>` **get_md5** **(** :ref:`String<class_String>` path **)** |const|
|
|
|
|
|
|
+- :ref:`String<class_String>` **get_md5** **(** :ref:`String<class_String>` path **)** |static|
|
|
|
|
|
|
Returns an MD5 String representing the file at the given path or an empty :ref:`String<class_String>` on failure.
|
|
Returns an MD5 String representing the file at the given path or an empty :ref:`String<class_String>` on failure.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_modified_time:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_modified_time:
|
|
|
|
|
|
-- :ref:`int<class_int>` **get_modified_time** **(** :ref:`String<class_String>` file **)** |const|
|
|
|
|
|
|
+- :ref:`int<class_int>` **get_modified_time** **(** :ref:`String<class_String>` file **)** |static|
|
|
|
|
|
|
Returns the last time the ``file`` was modified in Unix timestamp format or returns a :ref:`String<class_String>` "ERROR IN ``file``". This Unix timestamp can be converted to another format using the :ref:`Time<class_Time>` singleton.
|
|
Returns the last time the ``file`` was modified in Unix timestamp format or returns a :ref:`String<class_String>` "ERROR IN ``file``". This Unix timestamp can be converted to another format using the :ref:`Time<class_Time>` singleton.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_pascal_string:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_open_error:
|
|
|
|
+
|
|
|
|
+- :ref:`Error<enum_@GlobalScope_Error>` **get_open_error** **(** **)** |static|
|
|
|
|
+
|
|
|
|
+Returns the result of the last :ref:`open<class_FileAccess_method_open>` call in the current thread.
|
|
|
|
+
|
|
|
|
+----
|
|
|
|
+
|
|
|
|
+.. _class_FileAccess_method_get_pascal_string:
|
|
|
|
|
|
- :ref:`String<class_String>` **get_pascal_string** **(** **)**
|
|
- :ref:`String<class_String>` **get_pascal_string** **(** **)**
|
|
|
|
|
|
@@ -437,7 +446,7 @@ Text is interpreted as being UTF-8 encoded.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_path:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_path:
|
|
|
|
|
|
- :ref:`String<class_String>` **get_path** **(** **)** |const|
|
|
- :ref:`String<class_String>` **get_path** **(** **)** |const|
|
|
|
|
|
|
@@ -445,7 +454,7 @@ Returns the path as a :ref:`String<class_String>` for the current open file.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_path_absolute:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_path_absolute:
|
|
|
|
|
|
- :ref:`String<class_String>` **get_path_absolute** **(** **)** |const|
|
|
- :ref:`String<class_String>` **get_path_absolute** **(** **)** |const|
|
|
|
|
|
|
@@ -453,7 +462,7 @@ Returns the absolute path as a :ref:`String<class_String>` for the current open
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_position:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_position:
|
|
|
|
|
|
- :ref:`int<class_int>` **get_position** **(** **)** |const|
|
|
- :ref:`int<class_int>` **get_position** **(** **)** |const|
|
|
|
|
|
|
@@ -461,7 +470,7 @@ Returns the file cursor's position.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_real:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_real:
|
|
|
|
|
|
- :ref:`float<class_float>` **get_real** **(** **)** |const|
|
|
- :ref:`float<class_float>` **get_real** **(** **)** |const|
|
|
|
|
|
|
@@ -469,15 +478,15 @@ Returns the next bits from the file as a floating-point number.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_sha256:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_sha256:
|
|
|
|
|
|
-- :ref:`String<class_String>` **get_sha256** **(** :ref:`String<class_String>` path **)** |const|
|
|
|
|
|
|
+- :ref:`String<class_String>` **get_sha256** **(** :ref:`String<class_String>` path **)** |static|
|
|
|
|
|
|
Returns a SHA-256 :ref:`String<class_String>` representing the file at the given path or an empty :ref:`String<class_String>` on failure.
|
|
Returns a SHA-256 :ref:`String<class_String>` representing the file at the given path or an empty :ref:`String<class_String>` on failure.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_get_var:
|
|
|
|
|
|
+.. _class_FileAccess_method_get_var:
|
|
|
|
|
|
- :ref:`Variant<class_Variant>` **get_var** **(** :ref:`bool<class_bool>` allow_objects=false **)** |const|
|
|
- :ref:`Variant<class_Variant>` **get_var** **(** :ref:`bool<class_bool>` allow_objects=false **)** |const|
|
|
|
|
|
|
@@ -487,7 +496,7 @@ Returns the next :ref:`Variant<class_Variant>` value from the file. If ``allow_o
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_is_open:
|
|
|
|
|
|
+.. _class_FileAccess_method_is_open:
|
|
|
|
|
|
- :ref:`bool<class_bool>` **is_open** **(** **)** |const|
|
|
- :ref:`bool<class_bool>` **is_open** **(** **)** |const|
|
|
|
|
|
|
@@ -495,43 +504,51 @@ Returns ``true`` if the file is currently opened.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_open:
|
|
|
|
|
|
+.. _class_FileAccess_method_open:
|
|
|
|
+
|
|
|
|
+- :ref:`FileAccess<class_FileAccess>` **open** **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` flags **)** |static|
|
|
|
|
|
|
-- :ref:`Error<enum_@GlobalScope_Error>` **open** **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_File_ModeFlags>` flags **)**
|
|
|
|
|
|
+Creates a new ``FileAccess`` object and opens the file for writing or reading, depending on the flags.
|
|
|
|
|
|
-Opens the file for writing or reading, depending on the flags.
|
|
|
|
|
|
+Returns ``null`` if opening the file failed. You can use :ref:`get_open_error<class_FileAccess_method_get_open_error>` to check the error that occurred.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_open_compressed:
|
|
|
|
|
|
+.. _class_FileAccess_method_open_compressed:
|
|
|
|
|
|
-- :ref:`Error<enum_@GlobalScope_Error>` **open_compressed** **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_File_ModeFlags>` mode_flags, :ref:`CompressionMode<enum_File_CompressionMode>` compression_mode=0 **)**
|
|
|
|
|
|
+- :ref:`FileAccess<class_FileAccess>` **open_compressed** **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` mode_flags, :ref:`CompressionMode<enum_FileAccess_CompressionMode>` compression_mode=0 **)** |static|
|
|
|
|
|
|
-Opens a compressed file for reading or writing.
|
|
|
|
|
|
+Creates a new ``FileAccess`` object and opens a compressed file for reading or writing.
|
|
|
|
|
|
-\ **Note:** :ref:`open_compressed<class_File_method_open_compressed>` can only read files that were saved by Godot, not third-party compression formats. See `GitHub issue #28999 <https://github.com/godotengine/godot/issues/28999>`__ for a workaround.
|
|
|
|
|
|
+\ **Note:** :ref:`open_compressed<class_FileAccess_method_open_compressed>` can only read files that were saved by Godot, not third-party compression formats. See `GitHub issue #28999 <https://github.com/godotengine/godot/issues/28999>`__ for a workaround.
|
|
|
|
+
|
|
|
|
+Returns ``null`` if opening the file failed. You can use :ref:`get_open_error<class_FileAccess_method_get_open_error>` to check the error that occurred.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_open_encrypted:
|
|
|
|
|
|
+.. _class_FileAccess_method_open_encrypted:
|
|
|
|
|
|
-- :ref:`Error<enum_@GlobalScope_Error>` **open_encrypted** **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_File_ModeFlags>` mode_flags, :ref:`PackedByteArray<class_PackedByteArray>` key **)**
|
|
|
|
|
|
+- :ref:`FileAccess<class_FileAccess>` **open_encrypted** **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` mode_flags, :ref:`PackedByteArray<class_PackedByteArray>` key **)** |static|
|
|
|
|
|
|
-Opens an encrypted file in write or read mode. You need to pass a binary key to encrypt/decrypt it.
|
|
|
|
|
|
+Creates a new ``FileAccess`` object and opens an encrypted file in write or read mode. You need to pass a binary key to encrypt/decrypt it.
|
|
|
|
|
|
\ **Note:** The provided key must be 32 bytes long.
|
|
\ **Note:** The provided key must be 32 bytes long.
|
|
|
|
|
|
|
|
+Returns ``null`` if opening the file failed. You can use :ref:`get_open_error<class_FileAccess_method_get_open_error>` to check the error that occurred.
|
|
|
|
+
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_open_encrypted_with_pass:
|
|
|
|
|
|
+.. _class_FileAccess_method_open_encrypted_with_pass:
|
|
|
|
+
|
|
|
|
+- :ref:`FileAccess<class_FileAccess>` **open_encrypted_with_pass** **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_FileAccess_ModeFlags>` mode_flags, :ref:`String<class_String>` pass **)** |static|
|
|
|
|
|
|
-- :ref:`Error<enum_@GlobalScope_Error>` **open_encrypted_with_pass** **(** :ref:`String<class_String>` path, :ref:`ModeFlags<enum_File_ModeFlags>` mode_flags, :ref:`String<class_String>` pass **)**
|
|
|
|
|
|
+Creates a new ``FileAccess`` object and opens an encrypted file in write or read mode. You need to pass a password to encrypt/decrypt it.
|
|
|
|
|
|
-Opens an encrypted file in write or read mode. You need to pass a password to encrypt/decrypt it.
|
|
|
|
|
|
+Returns ``null`` if opening the file failed. You can use :ref:`get_open_error<class_FileAccess_method_get_open_error>` to check the error that occurred.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_seek:
|
|
|
|
|
|
+.. _class_FileAccess_method_seek:
|
|
|
|
|
|
- void **seek** **(** :ref:`int<class_int>` position **)**
|
|
- void **seek** **(** :ref:`int<class_int>` position **)**
|
|
|
|
|
|
@@ -539,7 +556,7 @@ Changes the file reading/writing cursor to the specified position (in bytes from
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_seek_end:
|
|
|
|
|
|
+.. _class_FileAccess_method_seek_end:
|
|
|
|
|
|
- void **seek_end** **(** :ref:`int<class_int>` position=0 **)**
|
|
- void **seek_end** **(** :ref:`int<class_int>` position=0 **)**
|
|
|
|
|
|
@@ -549,7 +566,7 @@ Changes the file reading/writing cursor to the specified position (in bytes from
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_16:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_16:
|
|
|
|
|
|
- void **store_16** **(** :ref:`int<class_int>` value **)**
|
|
- void **store_16** **(** :ref:`int<class_int>` value **)**
|
|
|
|
|
|
@@ -557,7 +574,7 @@ Stores an integer as 16 bits in the file.
|
|
|
|
|
|
\ **Note:** The ``value`` should lie in the interval ``[0, 2^16 - 1]``. Any other value will overflow and wrap around.
|
|
\ **Note:** The ``value`` should lie in the interval ``[0, 2^16 - 1]``. Any other value will overflow and wrap around.
|
|
|
|
|
|
-To store a signed integer, use :ref:`store_64<class_File_method_store_64>` or store a signed integer from the interval ``[-2^15, 2^15 - 1]`` (i.e. keeping one bit for the signedness) and compute its sign manually when reading. For example:
|
|
|
|
|
|
+To store a signed integer, use :ref:`store_64<class_FileAccess_method_store_64>` or store a signed integer from the interval ``[-2^15, 2^15 - 1]`` (i.e. keeping one bit for the signedness) and compute its sign manually when reading. For example:
|
|
|
|
|
|
|
|
|
|
.. tabs::
|
|
.. tabs::
|
|
@@ -571,8 +588,7 @@ To store a signed integer, use :ref:`store_64<class_File_method_store_64>` or st
|
|
return (unsigned + MAX_15B) % MAX_16B - MAX_15B
|
|
return (unsigned + MAX_15B) % MAX_16B - MAX_15B
|
|
|
|
|
|
func _ready():
|
|
func _ready():
|
|
- var f = File.new()
|
|
|
|
- f.open("user://file.dat", File.WRITE_READ)
|
|
|
|
|
|
+ var f = FileAccess.open("user://file.dat", FileAccess.WRITE_READ)
|
|
f.store_16(-42) # This wraps around and stores 65494 (2^16 - 42).
|
|
f.store_16(-42) # This wraps around and stores 65494 (2^16 - 42).
|
|
f.store_16(121) # In bounds, will store 121.
|
|
f.store_16(121) # In bounds, will store 121.
|
|
f.seek(0) # Go back to start to read the stored value.
|
|
f.seek(0) # Go back to start to read the stored value.
|
|
@@ -585,8 +601,7 @@ To store a signed integer, use :ref:`store_64<class_File_method_store_64>` or st
|
|
|
|
|
|
public override void _Ready()
|
|
public override void _Ready()
|
|
{
|
|
{
|
|
- var f = new File();
|
|
|
|
- f.Open("user://file.dat", File.ModeFlags.WriteRead);
|
|
|
|
|
|
+ using var f = FileAccess.Open("user://file.dat", FileAccess.ModeFlags.WriteRead);
|
|
f.Store16(unchecked((ushort)-42)); // This wraps around and stores 65494 (2^16 - 42).
|
|
f.Store16(unchecked((ushort)-42)); // This wraps around and stores 65494 (2^16 - 42).
|
|
f.Store16(121); // In bounds, will store 121.
|
|
f.Store16(121); // In bounds, will store 121.
|
|
f.Seek(0); // Go back to start to read the stored value.
|
|
f.Seek(0); // Go back to start to read the stored value.
|
|
@@ -600,7 +615,7 @@ To store a signed integer, use :ref:`store_64<class_File_method_store_64>` or st
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_32:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_32:
|
|
|
|
|
|
- void **store_32** **(** :ref:`int<class_int>` value **)**
|
|
- void **store_32** **(** :ref:`int<class_int>` value **)**
|
|
|
|
|
|
@@ -608,11 +623,11 @@ Stores an integer as 32 bits in the file.
|
|
|
|
|
|
\ **Note:** The ``value`` should lie in the interval ``[0, 2^32 - 1]``. Any other value will overflow and wrap around.
|
|
\ **Note:** The ``value`` should lie in the interval ``[0, 2^32 - 1]``. Any other value will overflow and wrap around.
|
|
|
|
|
|
-To store a signed integer, use :ref:`store_64<class_File_method_store_64>`, or convert it manually (see :ref:`store_16<class_File_method_store_16>` for an example).
|
|
|
|
|
|
+To store a signed integer, use :ref:`store_64<class_FileAccess_method_store_64>`, or convert it manually (see :ref:`store_16<class_FileAccess_method_store_16>` for an example).
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_64:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_64:
|
|
|
|
|
|
- void **store_64** **(** :ref:`int<class_int>` value **)**
|
|
- void **store_64** **(** :ref:`int<class_int>` value **)**
|
|
|
|
|
|
@@ -622,7 +637,7 @@ Stores an integer as 64 bits in the file.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_8:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_8:
|
|
|
|
|
|
- void **store_8** **(** :ref:`int<class_int>` value **)**
|
|
- void **store_8** **(** :ref:`int<class_int>` value **)**
|
|
|
|
|
|
@@ -630,11 +645,11 @@ Stores an integer as 8 bits in the file.
|
|
|
|
|
|
\ **Note:** The ``value`` should lie in the interval ``[0, 255]``. Any other value will overflow and wrap around.
|
|
\ **Note:** The ``value`` should lie in the interval ``[0, 255]``. Any other value will overflow and wrap around.
|
|
|
|
|
|
-To store a signed integer, use :ref:`store_64<class_File_method_store_64>`, or convert it manually (see :ref:`store_16<class_File_method_store_16>` for an example).
|
|
|
|
|
|
+To store a signed integer, use :ref:`store_64<class_FileAccess_method_store_64>`, or convert it manually (see :ref:`store_16<class_FileAccess_method_store_16>` for an example).
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_buffer:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_buffer:
|
|
|
|
|
|
- void **store_buffer** **(** :ref:`PackedByteArray<class_PackedByteArray>` buffer **)**
|
|
- void **store_buffer** **(** :ref:`PackedByteArray<class_PackedByteArray>` buffer **)**
|
|
|
|
|
|
@@ -642,7 +657,7 @@ Stores the given array of bytes in the file.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_csv_line:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_csv_line:
|
|
|
|
|
|
- void **store_csv_line** **(** :ref:`PackedStringArray<class_PackedStringArray>` values, :ref:`String<class_String>` delim="," **)**
|
|
- void **store_csv_line** **(** :ref:`PackedStringArray<class_PackedStringArray>` values, :ref:`String<class_String>` delim="," **)**
|
|
|
|
|
|
@@ -652,7 +667,7 @@ Text will be encoded as UTF-8.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_double:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_double:
|
|
|
|
|
|
- void **store_double** **(** :ref:`float<class_float>` value **)**
|
|
- void **store_double** **(** :ref:`float<class_float>` value **)**
|
|
|
|
|
|
@@ -660,7 +675,7 @@ Stores a floating-point number as 64 bits in the file.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_float:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_float:
|
|
|
|
|
|
- void **store_float** **(** :ref:`float<class_float>` value **)**
|
|
- void **store_float** **(** :ref:`float<class_float>` value **)**
|
|
|
|
|
|
@@ -668,7 +683,7 @@ Stores a floating-point number as 32 bits in the file.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_line:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_line:
|
|
|
|
|
|
- void **store_line** **(** :ref:`String<class_String>` line **)**
|
|
- void **store_line** **(** :ref:`String<class_String>` line **)**
|
|
|
|
|
|
@@ -676,7 +691,7 @@ Appends ``line`` to the file followed by a line return character (``\n``), encod
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_pascal_string:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_pascal_string:
|
|
|
|
|
|
- void **store_pascal_string** **(** :ref:`String<class_String>` string **)**
|
|
- void **store_pascal_string** **(** :ref:`String<class_String>` string **)**
|
|
|
|
|
|
@@ -686,7 +701,7 @@ Text will be encoded as UTF-8.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_real:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_real:
|
|
|
|
|
|
- void **store_real** **(** :ref:`float<class_float>` value **)**
|
|
- void **store_real** **(** :ref:`float<class_float>` value **)**
|
|
|
|
|
|
@@ -694,17 +709,17 @@ Stores a floating-point number in the file.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_string:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_string:
|
|
|
|
|
|
- void **store_string** **(** :ref:`String<class_String>` string **)**
|
|
- void **store_string** **(** :ref:`String<class_String>` string **)**
|
|
|
|
|
|
Appends ``string`` to the file without a line return, encoding the text as UTF-8.
|
|
Appends ``string`` to the file without a line return, encoding the text as UTF-8.
|
|
|
|
|
|
-\ **Note:** This method is intended to be used to write text files. The string is stored as a UTF-8 encoded buffer without string length or terminating zero, which means that it can't be loaded back easily. If you want to store a retrievable string in a binary file, consider using :ref:`store_pascal_string<class_File_method_store_pascal_string>` instead. For retrieving strings from a text file, you can use ``get_buffer(length).get_string_from_utf8()`` (if you know the length) or :ref:`get_as_text<class_File_method_get_as_text>`.
|
|
|
|
|
|
+\ **Note:** This method is intended to be used to write text files. The string is stored as a UTF-8 encoded buffer without string length or terminating zero, which means that it can't be loaded back easily. If you want to store a retrievable string in a binary file, consider using :ref:`store_pascal_string<class_FileAccess_method_store_pascal_string>` instead. For retrieving strings from a text file, you can use ``get_buffer(length).get_string_from_utf8()`` (if you know the length) or :ref:`get_as_text<class_FileAccess_method_get_as_text>`.
|
|
|
|
|
|
----
|
|
----
|
|
|
|
|
|
-.. _class_File_method_store_var:
|
|
|
|
|
|
+.. _class_FileAccess_method_store_var:
|
|
|
|
|
|
- void **store_var** **(** :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` full_objects=false **)**
|
|
- void **store_var** **(** :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` full_objects=false **)**
|
|
|
|
|