From b84714055bf75df5edafe7e434e6cf8915c0aea0 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Mon, 24 May 2021 19:42:37 +0100 Subject: [PATCH] Clarify that eof_reached() cannot be used to check if more data is available --- doc/classes/File.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/classes/File.xml b/doc/classes/File.xml index 42ec0a75dbc..610db56b1b9 100644 --- a/doc/classes/File.xml +++ b/doc/classes/File.xml @@ -40,8 +40,12 @@ - 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() < file.get_len(): + # Read data + [/codeblock]