#store_line() causing next line's text characters getting removed

1 messages · Page 1 of 1 (latest)

acoustic whale
#

When i try a insert new line using store_line(), it causes the next line (in case of this screenshot, line 1 hello) get the initial letters removed and i'm trying to make it insert a new line without affect the next line

lost temple
#

you override position 1 with h, two with linebreak, so ofc you're missing 2 characters of hello… the content does not just get shifted

acoustic whale
#

i see

#

is there a function of FileAccess that appends a new line instead of override?

lost temple
#

that's not how file systems are designed to work. You can read it into memory, modify it, write it. If your file is too big for memory you'll have to work with buffers or use piping on your OS to let it handle the details

lean mortar
lean mortar
#

To put the cursor at the end, and then write your data.

lean mortar
lean mortar
#

just did this on the command line 😛

lost temple
#

I'm not arguing that you can change files, just that you can't append files in the way that you just write the few bytes you wanna insert and be done with it... that's not how the filesystem works

lean mortar
lost temple
#

you can append at the end and get away with writing the few bytes, but if you wanna change the start, you have to rewrite everything

#

believe what you want

lean mortar
#

If, as a user/dev/player/whatever, I need to write hello in front of world, I can do that. As a user, I'm not going to care/worry about what happens on the disk itself. As long as in the end it says hello world, you're good to go.

#

It's not like you're manually flipping bits with a tiny magnet to put hello world on disk. 🙄

lost temple
#

just read my responses, it's not like you're disagreeing with anything I said

acoustic whale
lost temple
#

I just mentioned the typical godot fileaccess possibilities (read all, modify in godot, write all or use get_buffer set_buffer) to achieve the modification, because OP probably does not want to accommodate every target OS' terminal solutions to do this task