diff options
author | Max Hilbrunner <mhilbrunner@users.noreply.github.com> | 2021-09-16 00:19:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-16 00:19:35 +0200 |
commit | e156b0cc193fdcca4ef41a91d9ba03efdc0a4e98 (patch) | |
tree | ca863996b89745c91d9f24c8173e54f5ca32a112 /doc | |
parent | f4b088c2d7e64fcc29ed1dbc22dd426f32b933c3 (diff) | |
parent | 570d65cd98ac7bbae9958342671e341cff73a8a0 (diff) |
Merge pull request #49041 from madmiraal/fix-docs-4085
Clarify that eof_reached() cannot be used to check if more data is available
Diffstat (limited to 'doc')
-rw-r--r-- | doc/classes/File.xml | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/doc/classes/File.xml b/doc/classes/File.xml index 8ecdc8b220..cf08029c72 100644 --- a/doc/classes/File.xml +++ b/doc/classes/File.xml @@ -58,8 +58,20 @@ <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_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() < file.get_length(): + # Read data + [/gdscript] + [csharp] + while (file.GetPosition() < file.GetLength()) + { + // Read data + } + [/csharp] + [/codeblocks] </description> </method> <method name="file_exists" qualifiers="const"> |