-
Notifications
You must be signed in to change notification settings - Fork 401
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
Feature request: love.filesystem.newTempFile #2024
Comments
What sort of things would you use this for? I'm not sure I like the idea of having a step to clean up files, because LÖVE ultimately doesn't control how it closes (it may crash or be force-quit etc. depending on what people do.) |
Not the OP, but it sounds like they just want access to the platform-equivalent 'tmpfile' system call, which if used would mean there'd be no cleanup to register as the operating system itself would handle that. I apologize but I'm not able to find a good direct link for a pre-built system call on Apple iOS devices to do this. This is mostly used on desktop platforms for various purposes relating to building a file such as a game save then copying it over to a permanent location as a single operation when done, so that in case of a crash temporary files won't accumulate and won't corrupt the save game without having to assemble the whole save-file in memory first. |
Overall I'd rather implement exactly what people actually want/need rather than a more general temp file API - otherwise situations like this can happen libsdl-org/SDL#9256 That being said, from what I understand some uses of temp files are actually extremely hard or even impossible to do in a way that's atomic and safe across different platforms. I also don't want to add an API that seems like it's intended to be safe but actually can't be in practice. So we'd need to do a lot of research into the specifics of individual use cases before implementing anything, I think. |
The only two I can think of that's a reasonably sane use, one would be the example I gave above honestly and the other a strained variation of it that doesn't map well to Lua semantics at all so I'll skip it. Realistically since there's no piecemeal assembling of files in Love2D anyways only an atomic-ish "replace the whole file with this data" there's no way to really benefit from this, for all use-cases I can think of looking across all manner of game engines I'm poking at... the existing filesystem.write() just does what's needed. If in doubt write to a fixed file for the purpose/phase in the code, then .write(.read()) to its final destination is as atomic as one can get in Love2D AFAIK? |
this hasn't been true for some time, see File:write and File:seek |
Fwiw on our game we had a numbered backup system for the purposes of safe save files, you don't necessarily need a temporary file; instead you rotate your files and do redundancy checks |
yeah, i was actually implementing a replay system, in my case i just write it to a certain position in the save dir. |
there are two ways this could be implemented:
additionally, some way to easily move a temporary file to a permanent file would be nice.
The text was updated successfully, but these errors were encountered: