Skip to content
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

op_chmod: throw on Windows #4446

Merged
merged 1 commit into from
Mar 20, 2020
Merged

op_chmod: throw on Windows #4446

merged 1 commit into from
Mar 20, 2020

Conversation

dubiousjim
Copy link
Contributor

Currently chmod is a noop on Windows, while analogous functions like
chown and umask throw (see #4306). Symlink also currently throws, but
that can be implemented on Windows, it just hasn't been done yet
(see #815, an implementation was crafted but there were issues that
haven't been resolved yet).

It's possible to implement chmod in Windows to a limited degree: Rust
lets one make Windows files read-only. But the API for how this should
work hasn't been settled (see #4357). Until we do implement chmod on
Windows, perhaps we should make it throw like the other
Windows-unimplemented functions in /cli/ops/fs.rs do?

If so, this PR provides an implementation, and fixes tests accordingly.

Note that the current implementation of writeFile applies its mode
option to the file regardless of whether the file was created (and does
so using chmod, so it has to be touched by this PR). A forthcoming PR in
the #4017 series will make writeFile instead use the new mode option
in open for new files, and so no longer rely on chmod.

Currently chmod is a noop on Windows, while analogous functions like
chown and umask throw (see denoland#4306). Symlink also currently throws, but
that can be implemented on Windows, it just hasn't been done yet
(see denoland#815, an implementation was crafted but there were issues that
haven't been resolved yet).

It's possible to implement chmod in Windows to a limited degree: Rust
lets one make Windows files read-only. But the API for how this should
work hasn't been settled (see denoland#4357). Until we do implement chmod on
Windows, perhaps we should make it throw like the other
Windows-unimplemented functions in /cli/ops/fs.rs do?

If so, this PR provides an implementation, and fixes tests accordingly.

Note that the current implementation of writeFile applies its `mode`
option to the file regardless of whether the file was created (and does
so using chmod, so it has to be touched by this PR). A forthcoming PR in
the denoland#4017 series will make writeFile instead use the new `mode` option
in open for new files, and so no longer rely on chmod.
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants