ACP Implementation of PermissionsExt for Windows #152995
ACP Implementation of PermissionsExt for Windows #152995asder8215 wants to merge 2 commits intorust-lang:mainfrom
Conversation
|
|
This comment has been minimized.
This comment has been minimized.
00739a8 to
2daf248
Compare
This comment has been minimized.
This comment has been minimized.
2daf248 to
29689a6
Compare
This comment has been minimized.
This comment has been minimized.
29689a6 to
b752775
Compare
This comment has been minimized.
This comment has been minimized.
b752775 to
23a096f
Compare
library/std/src/os/windows/fs.rs
Outdated
| /// let mut permissions = Permissions::set_file_attributes(my_file_attr); | ||
| /// assert_eq!(permissions.mode(), my_file_attr); | ||
| /// ``` | ||
| pub trait PermissionsExt { |
There was a problem hiding this comment.
Permissions struct doesn't have a Sealed trait bound (the Unix version of PermissionsExt doesn't use a Sealed trait bound either), so I'm unsure if this should be done here.
There was a problem hiding this comment.
Any new structs like this should be sealed. The reason the Unix version of PermissionExt doesn't is an historical artefact and one we'd love to fix. Otherwise it makes adding any functions a breaking change (this can be worked around by adding PermissionExt2 but we'd rather avoid that if possible).
This comment has been minimized.
This comment has been minimized.
23a096f to
3ed985e
Compare
This comment has been minimized.
This comment has been minimized.
…rivate methods in FilePermissions struct (to be decided in PR whether to use or remove)
3ed985e to
696ce60
Compare
library/std/src/os/windows/fs.rs
Outdated
| /// | ||
| /// // readonly and hidden file attributes that we | ||
| /// // want to add to existing file | ||
| /// let my_file_attr = 0x1 | 0x2; |
There was a problem hiding this comment.
Given this is a public example, this should use constants instead of magic values, even if that means defining the constants right about this line.
library/std/src/os/windows/fs.rs
Outdated
| /// ); | ||
| /// Ok(()) | ||
| /// } | ||
| /// ``` |
There was a problem hiding this comment.
Actually this whole example seems much more like a test than an example. I think it's better for users if examples are kept short and to the point.
library/std/src/sys/fs/windows.rs
Outdated
| // According to SetFileAttributes, any other values | ||
| // passed to this should override FILE_ATTRIBUTE_NORMAL |
There was a problem hiding this comment.
Windows itself will override FILE_ATTRIBUTE_NORMAL if another attribute is present so I'm not sure it's necessary for us to do it. But if we do do it then I'd rather use a bitmask rather than repeating if self.normal() each time. Or maybe an internal-only helper function.
|
I'll get to updating this PR later today! To note, the doctest/example was inspired from the Unix version. I mirrored writing it in the way Unix doc for I'll try and see if I can apply the Thanks for taking a look at this PR @ChrisDenton! |
You should just be able implement
Yeah, after looking at the Unix example I do find that a bit verbose. In either case, considering the example is |
…d out FILE_ATTRIBUTE_NORMAL in private methods within FilePermissions
|
If there are no compilation errors, then yea I've added your feedback. Let me know if the doc comments for On a side note, I've been looking at |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
I'm down to update the Unix example in a separate PR to reduce verbosity. As for testing the functions here, where would be the appropriate place to do that for this PR? Moreover, does CI here run Windows tests? I've been wondering that a bit because in my Reverse Ancestor PR, I have Windows tests there for paths with Prefix components, but I didn't see anything in CI that mentions that it ran my Windows test (and passes). |
|
You'll need to |
Oh okay, I could do that. I was worried that I may not be allowed to do that if it's a breaking change. |

This PR implements the
PermissionsExtfor Windows ACP and adds file attribute methods inFilePermissionsstruct (to be decided whether we use them or not). See this tracking issue for further detail and links.I also added some comments in the code for clarifications about the ACP (e.g. whether we should have a
set_file_attributes()+from_file_attributes()method to mirror what unix'sPermissionsExtis doing).Also, some relevant links on this:
attribcommandNote: Apologies for the multiple forced push. I haven't set up my Windows VM up yet to compile and check the code, so I've been using the CI to help me with that.
r? @ChrisDenton