Page 1 of 1

Filesystem Loading and Writing Questions

Posted: Wed May 29, 2019 3:41 am
by LudvickToba
I'm working on writing to a file and loading it to act as a save feature. It works but I have a few of questions.

What's the difference between using love.filesystem.write() and using a File object to write (File:write())?

When I use either of these functions it does work when I read the file in LOVE, but when I open up the file in File Explorer (in the .love folder) it's still the same with none of the newly written data in it. Why does it do that?</t>

Re: Filesystem Loading and Writing Questions

Posted: Wed May 29, 2019 5:32 am
by grump
LudvickToba wrote: Wed May 29, 2019 3:41 am What's the difference between using love.filesystem.write() and using a File object to write (File:write())?
A File object gives you random access to the data, allowing you to seek and read/write arbitrary sized blocks of data at random positions, or to append at the end of the file. You can pass the File object around if required. If you want to save or load large files that don't fit into memory at once, File is your friend.

love.filesystem.write can only write a whole file at once and always replaces existing files with the same name. It is useful to write monolithic blocks of data from memory to disk.
When I use either of these functions it does work when I read the file in LOVE, but when I open up the file in File Explorer (in the .love folder) it's still the same with none of the newly written data in it.
Files are always created in the save folder. The documentation explains this right at the top.