Merge pull request #107938 from krishnabm/patch-1
Specifiy return value in several store methods in `FileAccess`
This commit is contained in:
@ -414,7 +414,7 @@
|
||||
<return type="bool" />
|
||||
<param index="0" name="value" type="int" />
|
||||
<description>
|
||||
Stores an integer as 8 bits in the file. This advances the file cursor by 1 byte.
|
||||
Stores an integer as 8 bits in the file. This advances the file cursor by 1 byte. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] The [param value] should lie in the interval [code][0, 255][/code]. Any other value will overflow and wrap around.
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
To store a signed integer, use [method store_64], or convert it manually (see [method store_16] for an example).
|
||||
@ -424,7 +424,7 @@
|
||||
<return type="bool" />
|
||||
<param index="0" name="value" type="int" />
|
||||
<description>
|
||||
Stores an integer as 16 bits in the file. This advances the file cursor by 2 bytes.
|
||||
Stores an integer as 16 bits in the file. This advances the file cursor by 2 bytes. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] The [param value] should lie in the interval [code][0, 2^16 - 1][/code]. Any other value will overflow and wrap around.
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
To store a signed integer, use [method store_64] or store a signed integer from the interval [code][-2^15, 2^15 - 1][/code] (i.e. keeping one bit for the signedness) and compute its sign manually when reading. For example:
|
||||
@ -466,7 +466,7 @@
|
||||
<return type="bool" />
|
||||
<param index="0" name="value" type="int" />
|
||||
<description>
|
||||
Stores an integer as 32 bits in the file. This advances the file cursor by 4 bytes.
|
||||
Stores an integer as 32 bits in the file. This advances the file cursor by 4 bytes. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] The [param value] should lie in the interval [code][0, 2^32 - 1][/code]. Any other value will overflow and wrap around.
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
To store a signed integer, use [method store_64], or convert it manually (see [method store_16] for an example).
|
||||
@ -476,7 +476,7 @@
|
||||
<return type="bool" />
|
||||
<param index="0" name="value" type="int" />
|
||||
<description>
|
||||
Stores an integer as 64 bits in the file. This advances the file cursor by 8 bytes.
|
||||
Stores an integer as 64 bits in the file. This advances the file cursor by 8 bytes. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] The [param value] must lie in the interval [code][-2^63, 2^63 - 1][/code] (i.e. be a valid [int] value).
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
</description>
|
||||
@ -485,7 +485,7 @@
|
||||
<return type="bool" />
|
||||
<param index="0" name="buffer" type="PackedByteArray" />
|
||||
<description>
|
||||
Stores the given array of bytes in the file. This advances the file cursor by the number of bytes written.
|
||||
Stores the given array of bytes in the file. This advances the file cursor by the number of bytes written. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
</description>
|
||||
</method>
|
||||
@ -495,7 +495,7 @@
|
||||
<param index="1" name="delim" type="String" default="","" />
|
||||
<description>
|
||||
Store the given [PackedStringArray] in the file as a line formatted in the CSV (Comma-Separated Values) format. You can pass a different delimiter [param delim] to use other than the default [code]","[/code] (comma). This delimiter must be one-character long.
|
||||
Text will be encoded as UTF-8.
|
||||
Text will be encoded as UTF-8. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
</description>
|
||||
</method>
|
||||
@ -503,7 +503,7 @@
|
||||
<return type="bool" />
|
||||
<param index="0" name="value" type="float" />
|
||||
<description>
|
||||
Stores a floating-point number as 64 bits in the file. This advances the file cursor by 8 bytes.
|
||||
Stores a floating-point number as 64 bits in the file. This advances the file cursor by 8 bytes. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
</description>
|
||||
</method>
|
||||
@ -511,7 +511,7 @@
|
||||
<return type="bool" />
|
||||
<param index="0" name="value" type="float" />
|
||||
<description>
|
||||
Stores a floating-point number as 32 bits in the file. This advances the file cursor by 4 bytes.
|
||||
Stores a floating-point number as 32 bits in the file. This advances the file cursor by 4 bytes. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
</description>
|
||||
</method>
|
||||
@ -519,7 +519,7 @@
|
||||
<return type="bool" />
|
||||
<param index="0" name="value" type="float" />
|
||||
<description>
|
||||
Stores a half-precision floating-point number as 16 bits in the file. This advances the file cursor by 2 bytes.
|
||||
Stores a half-precision floating-point number as 16 bits in the file. This advances the file cursor by 2 bytes. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
</description>
|
||||
</method>
|
||||
@ -527,7 +527,7 @@
|
||||
<return type="bool" />
|
||||
<param index="0" name="line" type="String" />
|
||||
<description>
|
||||
Stores [param line] in the file followed by a newline character ([code]\n[/code]), encoding the text as UTF-8. This advances the file cursor by the length of the line, after the newline character. The amount of bytes written depends on the UTF-8 encoded bytes, which may be different from [method String.length] which counts the number of UTF-32 codepoints.
|
||||
Stores [param line] in the file followed by a newline character ([code]\n[/code]), encoding the text as UTF-8. This advances the file cursor by the length of the line, after the newline character. The amount of bytes written depends on the UTF-8 encoded bytes, which may be different from [method String.length] which counts the number of UTF-32 codepoints. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
</description>
|
||||
</method>
|
||||
@ -535,7 +535,7 @@
|
||||
<return type="bool" />
|
||||
<param index="0" name="string" type="String" />
|
||||
<description>
|
||||
Stores the given [String] as a line in the file in Pascal format (i.e. also store the length of the string). Text will be encoded as UTF-8. This advances the file cursor by the number of bytes written depending on the UTF-8 encoded bytes, which may be different from [method String.length] which counts the number of UTF-32 codepoints.
|
||||
Stores the given [String] as a line in the file in Pascal format (i.e. also store the length of the string). Text will be encoded as UTF-8. This advances the file cursor by the number of bytes written depending on the UTF-8 encoded bytes, which may be different from [method String.length] which counts the number of UTF-32 codepoints. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
</description>
|
||||
</method>
|
||||
@ -544,7 +544,7 @@
|
||||
<param index="0" name="value" type="float" />
|
||||
<description>
|
||||
Stores a floating-point number in the file. This advances the file cursor by either 4 or 8 bytes, depending on the precision used by the current Godot build.
|
||||
If using a Godot build compiled with the [code]precision=single[/code] option (the default), this method will save a 32-bit float. Otherwise, if compiled with the [code]precision=double[/code] option, this will save a 64-bit float.
|
||||
If using a Godot build compiled with the [code]precision=single[/code] option (the default), this method will save a 32-bit float. Otherwise, if compiled with the [code]precision=double[/code] option, this will save a 64-bit float. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
</description>
|
||||
</method>
|
||||
@ -552,7 +552,7 @@
|
||||
<return type="bool" />
|
||||
<param index="0" name="string" type="String" />
|
||||
<description>
|
||||
Stores [param string] in the file without a newline character ([code]\n[/code]), encoding the text as UTF-8. This advances the file cursor by the length of the string in UTF-8 encoded bytes, which may be different from [method String.length] which counts the number of UTF-32 codepoints.
|
||||
Stores [param string] in the file without a newline character ([code]\n[/code]), encoding the text as UTF-8. This advances the file cursor by the length of the string in UTF-8 encoded bytes, which may be different from [method String.length] which counts the number of UTF-32 codepoints. Returns [code]true[/code] if the operation is successful.
|
||||
[b]Note:[/b] 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 [method store_pascal_string] instead. For retrieving strings from a text file, you can use [code]get_buffer(length).get_string_from_utf8()[/code] (if you know the length) or [method get_as_text].
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
</description>
|
||||
@ -562,7 +562,7 @@
|
||||
<param index="0" name="value" type="Variant" />
|
||||
<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). This advances the file cursor by the number of bytes written.
|
||||
Stores any Variant value in the file. If [param full_objects] is [code]true[/code], encoding objects is allowed (and can potentially include code). This advances the file cursor by the number of bytes written. Returns [code]true[/code] if the operation is successful.
|
||||
Internally, this uses the same encoding mechanism as the [method @GlobalScope.var_to_bytes] method, as described in the [url=$DOCS_URL/tutorials/io/binary_serialization_api.html]Binary serialization API[/url] documentation.
|
||||
[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.
|
||||
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
|
||||
|
||||
Reference in New Issue
Block a user