-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Expose a File.flush()
method to scripting
#44396
Conversation
I think this is certainly useful for things like storing game replays where you can continuously write to disk (at some fixed steps via chunks of data, of course), or saving procedurally generated world. |
Calling Edit: It seems the behaviour isn't consistent between the types. A packed file ( These problems are existing and not caused by this PR - though previously you couldn't trigger them in scripts due to the lack of the bind. Perhaps this is fine (it's certainly better than it was), and we should just open another ticket for the correction. |
Those problems should be treated on the same level, regardless of whether the functionality is exposed (because it's possible to do the same thing via C++ modules currently), so I'm for consistency in this case (and yes, if that's the case, people will report more issues with this, but I don't see nothing wrong with that).
I wonder what would be the alternative way to write compressed data? Perhaps the partial data/buffer should be manually compressed before write in this case (via |
Does it work in |
Bump. Could also use a rebase to make sure it builds fine after various refactorings. |
b7164a2
to
4d617fc
Compare
Rebased and tested on |
4d617fc
to
d7d4345
Compare
This can be used to ensure a file has its contents saved even if the project crashes or is killed by the user (among other use cases). See discussion in godotengine#29075.
d7d4345
to
ab39746
Compare
Thanks! |
Cherry-picked for 3.2.4. |
Follow-up to #44393.
This can be used to ensure a file has its contents saved even if the project crashes or is killed by the user (among other use cases).
Note: I couldn't test this as I get "File must be opened before use." when trying to create a new file following the File code sample in the class reference, even with a vanillamaster
build.Edit: Using
File.WRITE
instead ofFile.READ_WRITE
works for testing.See discussion in #29075.