Skip to content

Commit b9f0580

Browse files
committed
Merge pull request #107938 from krishnabm/patch-1
Specifiy return value in several store methods in `FileAccess`
2 parents a9cef6c + ef43409 commit b9f0580

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

doc/classes/FileAccess.xml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@
414414
<return type="bool" />
415415
<param index="0" name="value" type="int" />
416416
<description>
417-
Stores an integer as 8 bits in the file. This advances the file cursor by 1 byte.
417+
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.
418418
[b]Note:[/b] The [param value] should lie in the interval [code][0, 255][/code]. Any other value will overflow and wrap around.
419419
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
420420
To store a signed integer, use [method store_64], or convert it manually (see [method store_16] for an example).
@@ -424,7 +424,7 @@
424424
<return type="bool" />
425425
<param index="0" name="value" type="int" />
426426
<description>
427-
Stores an integer as 16 bits in the file. This advances the file cursor by 2 bytes.
427+
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.
428428
[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.
429429
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
430430
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 @@
466466
<return type="bool" />
467467
<param index="0" name="value" type="int" />
468468
<description>
469-
Stores an integer as 32 bits in the file. This advances the file cursor by 4 bytes.
469+
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.
470470
[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.
471471
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
472472
To store a signed integer, use [method store_64], or convert it manually (see [method store_16] for an example).
@@ -476,7 +476,7 @@
476476
<return type="bool" />
477477
<param index="0" name="value" type="int" />
478478
<description>
479-
Stores an integer as 64 bits in the file. This advances the file cursor by 8 bytes.
479+
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.
480480
[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).
481481
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
482482
</description>
@@ -485,7 +485,7 @@
485485
<return type="bool" />
486486
<param index="0" name="buffer" type="PackedByteArray" />
487487
<description>
488-
Stores the given array of bytes in the file. This advances the file cursor by the number of bytes written.
488+
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.
489489
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
490490
</description>
491491
</method>
@@ -495,47 +495,47 @@
495495
<param index="1" name="delim" type="String" default="&quot;,&quot;" />
496496
<description>
497497
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.
498-
Text will be encoded as UTF-8.
498+
Text will be encoded as UTF-8. Returns [code]true[/code] if the operation is successful.
499499
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
500500
</description>
501501
</method>
502502
<method name="store_double">
503503
<return type="bool" />
504504
<param index="0" name="value" type="float" />
505505
<description>
506-
Stores a floating-point number as 64 bits in the file. This advances the file cursor by 8 bytes.
506+
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.
507507
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
508508
</description>
509509
</method>
510510
<method name="store_float">
511511
<return type="bool" />
512512
<param index="0" name="value" type="float" />
513513
<description>
514-
Stores a floating-point number as 32 bits in the file. This advances the file cursor by 4 bytes.
514+
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.
515515
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
516516
</description>
517517
</method>
518518
<method name="store_half">
519519
<return type="bool" />
520520
<param index="0" name="value" type="float" />
521521
<description>
522-
Stores a half-precision floating-point number as 16 bits in the file. This advances the file cursor by 2 bytes.
522+
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.
523523
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
524524
</description>
525525
</method>
526526
<method name="store_line">
527527
<return type="bool" />
528528
<param index="0" name="line" type="String" />
529529
<description>
530-
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.
530+
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.
531531
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
532532
</description>
533533
</method>
534534
<method name="store_pascal_string">
535535
<return type="bool" />
536536
<param index="0" name="string" type="String" />
537537
<description>
538-
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.
538+
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.
539539
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
540540
</description>
541541
</method>
@@ -544,15 +544,15 @@
544544
<param index="0" name="value" type="float" />
545545
<description>
546546
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.
547-
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.
547+
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.
548548
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
549549
</description>
550550
</method>
551551
<method name="store_string">
552552
<return type="bool" />
553553
<param index="0" name="string" type="String" />
554554
<description>
555-
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.
555+
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.
556556
[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].
557557
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.
558558
</description>
@@ -562,7 +562,7 @@
562562
<param index="0" name="value" type="Variant" />
563563
<param index="1" name="full_objects" type="bool" default="false" />
564564
<description>
565-
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.
565+
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.
566566
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.
567567
[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.
568568
[b]Note:[/b] If an error occurs, the resulting value of the file position indicator is indeterminate.

0 commit comments

Comments
 (0)