diff options
Diffstat (limited to 'doc/classes/FileAccess.xml')
-rw-r--r-- | doc/classes/FileAccess.xml | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/doc/classes/FileAccess.xml b/doc/classes/FileAccess.xml index e52f897164..eda06d57da 100644 --- a/doc/classes/FileAccess.xml +++ b/doc/classes/FileAccess.xml @@ -153,6 +153,20 @@ Returns the last error that happened when trying to perform operations. Compare with the [code]ERR_FILE_*[/code] constants from [enum Error]. </description> </method> + <method name="get_file_as_bytes" qualifiers="static"> + <return type="PackedByteArray" /> + <param index="0" name="path" type="String" /> + <description> + Returns the whole [param path] file contents as a [PackedByteArray] without any decoding. + </description> + </method> + <method name="get_file_as_string" qualifiers="static"> + <return type="String" /> + <param index="0" name="path" type="String" /> + <description> + Returns the whole [param path] file contents as a [String]. Text is interpreted as being UTF-8 encoded. + </description> + </method> <method name="get_float" qualifiers="const"> <return type="float" /> <description> @@ -235,6 +249,7 @@ <param index="0" name="allow_objects" type="bool" default="false" /> <description> Returns the next [Variant] value from the file. If [param allow_objects] is [code]true[/code], decoding objects is allowed. + Internally, this uses the same decoding mechanism as the [method @GlobalScope.bytes_to_var] method. [b]Warning:[/b] Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution. </description> </method> @@ -334,8 +349,8 @@ f.Seek(0); // Go back to start to read the stored value. ushort read1 = f.Get16(); // 65494 ushort read2 = f.Get16(); // 121 - short converted1 = BitConverter.ToInt16(BitConverter.GetBytes(read1), 0); // -42 - short converted2 = BitConverter.ToInt16(BitConverter.GetBytes(read2), 0); // 121 + short converted1 = (short)read1; // -42 + short converted2 = (short)read2; // 121 } [/csharp] [/codeblocks] @@ -433,6 +448,7 @@ <param index="1" name="full_objects" type="bool" default="false" /> <description> Stores any Variant value in the file. If [param full_objects] is [code]true[/code], encoding objects is allowed (and can potentially include code). + Internally, this uses the same encoding mechanism as the [method @GlobalScope.var_to_bytes] method. [b]Note:[/b] Not all properties are included. Only properties that are configured with the [constant PROPERTY_USAGE_STORAGE] flag set will be serialized. You can add a new usage flag to a property by overriding the [method Object._get_property_list] method in your class. You can also check how property usage is configured by calling [method Object._get_property_list]. See [enum PropertyUsageFlags] for the possible usage flags. </description> </method> |