Repository navigation
FS constants says not all constants are available on all platforms, but it doesn't say which ones are available on what platforms #41591
Description
Activity
- addeddocIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.
on Jan 19, 2022 - addedfsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
on Jan 19, 2022 I've also got bitten by the missing
S_IWUSRon Windows.I think that this particular constant must be defined for Windows, since
chmod()is able to set this bit; perhaps other constants are in this category too.The constants not used on Windows can be omitted, but the documentation must explicitly mention this.
- addedgood first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
on Apr 15, 2022 I've added the "good first issue" label because it just needs someone to go and open a pull request.
@ilg-ul
S_IWUSRis missing on Windows because it's called_S_IWRITEthere (which node doesn't export.)You could open a pull request exporting
_S_IWRITEand_S_IREAD, or aliasing them toS_IWUSRandS_IRUSR.I took a look, and I identified in
node_constants.ccseveral definitions that add constants. Is this the correct location?If so, I suggest we alias the definitions like this:
#if defined(_WIN32) #include <io.h> // _S_IREAD _S_IWRITE #ifndef S_IRUSR #define S_IRUSR _S_IREAD #endif // S_IRUSR #ifndef S_IWUSR #define S_IWUSR _S_IWRITE #endif // S_IWUSR #endif
Is this what you mean?
Yes, that would work. Variations of that pattern are already in use elsewhere in the code base.
I added a small test to verify that the definitions are generated on Windows (the test passed), and I also added some explicit mentions in the documentation.
The CI checks passed.
Do I have to do anything more, or simply wait for a review?
I created a new PR, hopefully cleaner: #42757.
I replaced Fixes with Refs. Is this ok?
Btw, the patch also changes the documentation to mention which constants are available on Windows. Isn't this what you asked for?
Reacted by Claudia MeadowsBtw, the patch also changes the documentation to mention which constants are available on Windows. Isn't this what you asked for?
I didn't realize that - didn't see it in the summary and I didn't actually look at the patch in question. In that case, this can be resolved by that.
You can also suggest a separate PR with explicit columns in that tables to show which constants are available for which platforms.
- added a commit that references this issue
on Apr 25, 2022 - added a commit that references this issue
on Apr 28, 2022 - added a commit that references this issue
on May 31, 2022 - added a commit that references this issue
on Jun 27, 2022 - added a commit that references this issue
on Jul 12, 2022 - added a commit that references this issue
on Jul 31, 2022 - added a commit that references this issue
on Oct 10, 2022 - added a commit that references this issue
on Mar 21, 2024
Affected URL(s)
https://nodejs.org/api/fs.html#fsconstants
Description of the problem
It says the following:
However, this doesn't say anything else about the availability of various constants. In particular, none of the file mode constants are available on Windows and about half of the file type constants are also not present, but the docs don't even so much as hint at this. (I initially thought this to be a bug and filed #41590, so it's definitely confusing.) Part of what makes it non-obvious is the fact many of the various Unix-based constants (both in
fsand elsewhere like with many signals) are shimmed on Windows in terms of corresponding Windows APIs, and so I can't just assume for all of them. (In particular,fs.constants.O_DIRECTORYis missing from Windows despitefs.opendirusing Windows APIs similar to POSIX'sopendir- that one was very surprising.)Could the series of tables be updated to include platform availability for each relevant constant?