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

expected behaviour of fs.constants.W_OK #17508

Closed
ahmadnassri opened this issue Dec 6, 2017 · 7 comments
Closed

expected behaviour of fs.constants.W_OK #17508

ahmadnassri opened this issue Dec 6, 2017 · 7 comments
Labels
fs Issues and PRs related to the fs subsystem / file system. good first issue Issues that are suitable for first-time contributors.

Comments

@ahmadnassri
Copy link
Contributor

  • Version: tested on 7.x, 8.x, 9.x

according to the documentation:

fs.constants.W_OK - path can be written by the calling process

the description text reads as agnostic to the behaviour of the path existing or not, however in practice, this only works if the path exists:

const fs = require('fs')

fs.access('my-test-file', fs.constants.W_OK, console.log)

results in:

{ Error: ENOENT: no such file or directory, access 'my-test-file'  errno: -2,  code: 'ENOENT',  syscall: 'access',  path: 'my-test-file' }

I am not certain if the intended functionality is what's accurately described, meaning this is a technical bug, or if the description is lacking in clarity.

Happy to help address either through PR, I believe this is a documentation problem, so wanted to be sure before.

@cjihrig
Copy link
Contributor

cjihrig commented Dec 7, 2017

Documentation PR welcome. For inspiration, check out http://man7.org/linux/man-pages/man2/access.2.html. Of specific interest here:

The mode specifies the accessibility check(s) to be performed, and is either the value F_OK, or a mask consisting of the bitwise OR of one or more of R_OK, W_OK, and X_OK. F_OK tests for the existence of the file. R_OK, W_OK, and X_OK test whether the file exists and grants read, write, and execute permissions, respectively.

@ahmadnassri
Copy link
Contributor Author

upon further reading, I believe the issue I'm facing is due checking whether the file path is writable, instead of checking if the file's directory is writable.

in that context, technically the docs are correct, however, some examples would help.

I'll take a stab at improving the examples

@cjihrig
Copy link
Contributor

cjihrig commented Dec 7, 2017

I'm going to reopen this, because I agree that those docs could be improved. If you or anyone else makes a PR for the docs, then we can close this.

@cjihrig cjihrig reopened this Dec 7, 2017
@mscdex mscdex added the fs Issues and PRs related to the fs subsystem / file system. label Dec 7, 2017
@mfaheemakhtar
Copy link

Hi, I've tried improving the documentation of fs.access, take a look at my pull request #17578.

Thanks

@gireeshpunathil gireeshpunathil added the good first issue Issues that are suitable for first-time contributors. label Apr 28, 2018
@gireeshpunathil
Copy link
Member

#17578 was never landed but has enough content in for a first timer to pick and progress.

@BeniCheni
Copy link
Contributor

BeniCheni commented May 1, 2018

Hi @ gireeshpunathil (edited the comment to say hi to all previous commenters, or issue viewers instead 😅), would you mind if I pick up this first timer? I can work off the content of #17578 and give it a "spin".

@gireeshpunathil
Copy link
Member

sure, please go ahead.

MylesBorins pushed a commit that referenced this issue May 4, 2018
PR-URL: #20460
Fixes: #17508
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
MylesBorins pushed a commit that referenced this issue May 8, 2018
PR-URL: #20460
Fixes: #17508
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. good first issue Issues that are suitable for first-time contributors.
Projects
None yet
Development

No branches or pull requests

6 participants