-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
[FileAccess] Add methods to get/set "hidden" and "read-only" attributes on macOS/BSD and Windows. #80404
Conversation
This should also make it possible to implement godotengine/godot-proposals#801 if desired (though personally, I wouldn't do that for cross-platform consistency reasons). |
<param index="0" name="file" type="String" /> | ||
<param index="1" name="permissions" type="int" /> | ||
<description> | ||
Sets file UNIX permissions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to document what kind of values [param permissions] support (probably not the full blown description of possible permission values, but e.g. is it supposed to take 0x755
for the equivalent to chmod 755
?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chmod 755
is octal, so it takes0x1ED
(GDScript do not have octal support). Added a list of values to combine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we define an enum for these values then? The octal format is widespread and so it's easy to read with some experience, and this is less so. But maybe it's an overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An enum would be good for usability, but I think this might be a niche enough feature that it may not be worth it to add more cognitive overload in the FileAccess API by adding an enum with all these values.
I wouldn't oppose it if @bruvzg thinks it's worth adding, but we can also just wait to see if there's demand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to bitfield enum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work as expected on Windows.
One usability note: we could probably improve this error message now, when trying to write a readonly file. Or rather add an extra check before reaching this error and report the actual state of the file.
Safe save failed. This may be a permissions problem, but also may happen because you are running a paranoid antivirus. If this is the case, please switch to Windows Defender or disable the 'safe save' option in editor settings. This makes it work, but increases the risk of file corruption in a crash.
It's in FileAccessWindows::_close()
.
2954eee
to
f5ae23c
Compare
…es on macOS/BSD and Windows.
Thanks! |
Adds
(get)set_read_only_attribute
and(get)set_hidden_attribute
methods, and exposes them and methods to get/set UNIX permissions to the scripting API.Useful for making temporary files hidden on Windows, e.g. #80188 (review)