0 votes

I used

file.seek_end()
print(file.eof_reached())

it didn't work, it returns false, and then I used seek() and while to find the end of the file, but the became an endless loop. Basically, I am asking what special character does it consider to be the delimiter or symbol that it is the end of the file.

asked Jul 1, 2019 in Engine by Xian (241 points)

I think it relies on the C API for files ( http://www.cplusplus.com/reference/cstdio/fgetc/ ), which is supposed to return EOF when an attempt to read past the end of the file is made. seek_end() goes to the end, but does not perform a read, so... I'm not sure wether this is a bug or not.

Are you trying to stop reading a file inside a loop?

i wanted to reach the end of the file. But it wasn't working so i tried use a loop to move the cursor all the way to end of the file, but it resulted in a endless loop. This could only mean that there is no special character that acts as a delimiter for my file, which is why when i used seekend() it didn't work because it couldn't find the delimiter character, same reason why using the loop resulted in an endless loop, because it couldn't find that delimiter and resulted in reading beyond the original file, which could also mean my saving to file function is lacking. Which is why I am asking how seekend() works so that I can add a delimiter.

P.S. I tried the c or c++ delimiter which is "\0"

file.store_line("\0")

this resulted in an error

Can you upload that file or post the file content?

it was

(14:49:22) : test

i pre-appended a time to my text i wanted to store in my file. Guys thank for all your help for some reason after my project was removed from godot and re-added it the function runs properly and will search to the end now.

(14:49:37) : test
(14:50:8) : test

Promise no changes whatsoever. It just runs properly all of a sudden xD? I have no idea what happened. above u can see 2 lines it shows i was able to append.
I could explain how it happened. Yesterday afternoon I ran godot in my pc and it crashed instead of running. And so i used task manager to close it run it again. after which i noticed my project file was no longer in the list so i imported it back(it wasn't deleted). Afterwards I check for bugs but everything was the same so I ran the project only to find out it works now? I swear I have absolutely no idea what in the world just happened xD?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.