GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: define fs.constants.S_IWUSR & S_IRUSR for Win · nodejs/node@1281a48

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • fs.md
  • src
    • node_constants.cc
  • test/parallel
    • test-fs-constants.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/fs.md‎

Copy file name to clipboardExpand all lines: doc/api/fs.md
+17-1Lines changed: 17 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -6526,7 +6526,11 @@ operations.
65266526
65276527
The following constants are exported by `fs.constants`.
65286528
6529-
Not every constant will be available on every operating system.
6529+
Not every constant will be available on every operating system;
6530+
this is especially important for Windows, where many of the POSIX specific
6531+
definitions are not available.
6532+
For portable applications it is recommended to check for their presence
6533+
before use.
65306534
65316535
To use more than one constant, use the bitwise OR `|` operator.
65326536
@@ -6579,6 +6583,8 @@ The following constants are meant for use as the `mode` parameter passed to
65796583
</tr>
65806584
</table>
65816585
6586+
The definitions are also available on Windows.
6587+
65826588
##### File copy constants
65836589
65846590
The following constants are meant for use with [`fs.copyFile()`][].
@@ -6607,6 +6613,8 @@ The following constants are meant for use with [`fs.copyFile()`][].
66076613
</tr>
66086614
</table>
66096615
6616+
The definitions are also available on Windows.
6617+
66106618
##### File open constants
66116619
66126620
The following constants are meant for use with `fs.open()`.
@@ -6701,6 +6709,9 @@ The following constants are meant for use with `fs.open()`.
67016709
</tr>
67026710
</table>
67036711
6712+
On Windows, only `O_APPEND`, `O_CREAT`, `O_EXCL`, `O_RDONLY`, `O_RDWR`,
6713+
`O_TRUNC`, `O_WRONLY` and `UV_FS_O_FILEMAP` are available.
6714+
67046715
##### File type constants
67056716
67066717
The following constants are meant for use with the {fs.Stats} object's
@@ -6745,6 +6756,9 @@ The following constants are meant for use with the {fs.Stats} object's
67456756
</tr>
67466757
</table>
67476758
6759+
On Windows, only `S_IFCHR`, `S_IFDIR`, `S_IFLNK`, `S_IFMT`, and `S_IFREG`,
6760+
are available.
6761+
67486762
##### File mode constants
67496763
67506764
The following constants are meant for use with the {fs.Stats} object's
@@ -6805,6 +6819,8 @@ The following constants are meant for use with the {fs.Stats} object's
68056819
</tr>
68066820
</table>
68076821
6822+
On Windows, only `S_IRUSR` and `S_IWUSR` are available.
6823+
68086824
## Notes
68096825
68106826
### Ordering of callback and promise-based operations
Collapse file

‎src/node_constants.cc‎

Copy file name to clipboardExpand all lines: src/node_constants.cc
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@
4747
#include <dlfcn.h>
4848
#endif
4949

50+
#if defined(_WIN32)
51+
#include <io.h> // _S_IREAD _S_IWRITE
52+
#ifndef S_IRUSR
53+
#define S_IRUSR _S_IREAD
54+
#endif // S_IRUSR
55+
#ifndef S_IWUSR
56+
#define S_IWUSR _S_IWRITE
57+
#endif // S_IWUSR
58+
#endif
59+
5060
#include <cerrno>
5161
#include <csignal>
5262
#include <limits>
Collapse file

‎test/parallel/test-fs-constants.js‎

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
require('../common');
3+
const fs = require('fs');
4+
const assert = require('assert');
5+
6+
// Check if the two constants accepted by chmod() on Windows are defined.
7+
assert.notStrictEqual(fs.constants.S_IRUSR, undefined);
8+
assert.notStrictEqual(fs.constants.S_IWUSR, undefined);

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.