summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Admiraal <madmiraal@users.noreply.github.com>2021-05-24 18:56:34 +0100
committerMarcel Admiraal <madmiraal@users.noreply.github.com>2021-05-28 16:20:51 +0100
commit570d65cd98ac7bbae9958342671e341cff73a8a0 (patch)
tree63ae553b21b7a5535ff775ba90ed1708afe71679
parent364ea7f280a3f074795e542b16b1d0ec76cf6ce2 (diff)
Clarify that eof_reached() cannot be used to check if more data is available
-rw-r--r--doc/classes/File.xml16
1 files changed, 14 insertions, 2 deletions
diff --git a/doc/classes/File.xml b/doc/classes/File.xml
index 2206730523..b6df0a7d1e 100644
--- a/doc/classes/File.xml
+++ b/doc/classes/File.xml
@@ -60,8 +60,20 @@
<return type="bool">
</return>
<description>
- Returns [code]true[/code] if the file cursor has read past the end of the file.
- [b]Note:[/b] This function will still return [code]false[/code] while at the end of the file and only activates when reading past it. This can be confusing but it conforms to how low-level file access works in all operating systems. There is always [method get_length] and [method get_position] to implement a custom logic.
+ Returns [code]true[/code] if the file cursor has already read past the end of the file.
+ [b]Note:[/b] [code]eof_reached() == false[/code] cannot be used to check whether there is more data available. To loop while there is more data available, use:
+ [codeblocks]
+ [gdscript]
+ while file.get_position() &lt; file.get_length():
+ # Read data
+ [/gdscript]
+ [csharp]
+ while (file.GetPosition() &lt; file.GetLength())
+ {
+ // Read data
+ }
+ [/csharp]
+ [/codeblocks]
</description>
</method>
<method name="file_exists" qualifiers="const">