Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File.eof_reached() causes infinite while-loop on Android when read/write permissions aren't set #42959

Closed
SilvanaP opened this issue Oct 21, 2020 · 2 comments

Comments

@SilvanaP
Copy link

Godot version:
3.1

OS/device including version:
Android

Issue description:
I am trying to open an existing file and count the lines in there. Works like a charm on Windows, but crashes on Android because the code is stuck in the while-loop. It's a *.txt logfile that I try to open. I already did set the exporting-options so that my *.txt files should make it into the apk, but its still stuck in the loop. Also restarting Godot did not help.

Here's my code:

#savefile is a file I open in another method...
func calculateTotalLinecount():
	var totalcount = 0
	while !savefile.eof_reached():
		# iterate through all lines until the end of file is reached
		var line = savefile.get_line()
		totalcount += 1
	linenumber = totalcount

Here what the console says:
godotcrash

@Calinou
Copy link
Member

Calinou commented Oct 21, 2020

@SilvanaP Please upload a minimal reproduction project to make this easier to troubleshoot.

@SilvanaP
Copy link
Author

Argh...I found the problem. I had no read/write Permissions set >_<
Improvement suggestion: making more descriptive errors for such cases?

@Calinou Calinou changed the title [Android] eof_reached() causes infinite while-loop File.eof_reached() causes infinite while-loop on Android when read/write permissions aren't set Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants