Merge pull request #49042 from madmiraal/fix-docs-4085-3.x

[3.x] Clarify that eof_reached() cannot be used to check if more data is available
This commit is contained in:
Max Hilbrunner 2021-09-16 00:20:12 +02:00 committed by GitHub
commit 1d07feca54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,8 +38,12 @@
<method name="eof_reached" qualifiers="const">
<return type="bool" />
<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_len] 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:
[codeblock]
while file.get_position() &lt; file.get_len():
# Read data
[/codeblock]
</description>
</method>
<method name="file_exists" qualifiers="const">