| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 41c5108 commit 83a7949
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8766,12 +8766,14 @@ The following constants are meant for use with `fs.open()`. | |||
| 8766 | 8766 | <tr> | |
| 8767 | 8767 | <td><code>O_SYNC</code></td> | |
| 8768 | 8768 | <td>Flag indicating that the file is opened for synchronized I/O with write | |
| 8769 | - operations waiting for file integrity.</td> | ||
| 8769 | + operations waiting for file integrity. On Windows, this maps to | ||
| 8770 | + <code>FILE_FLAG_WRITE_THROUGH</code>.</td> | ||
| 8770 | 8771 | </tr> | |
| 8771 | 8772 | <tr> | |
| 8772 | 8773 | <td><code>O_DSYNC</code></td> | |
| 8773 | 8774 | <td>Flag indicating that the file is opened for synchronized I/O with write | |
| 8774 | - operations waiting for data integrity.</td> | ||
| 8775 | + operations waiting for data integrity. On Windows, this maps to | ||
| 8776 | + <code>FILE_FLAG_WRITE_THROUGH</code>.</td> | ||
| 8775 | 8777 | </tr> | |
| 8776 | 8778 | <tr> | |
| 8777 | 8779 | <td><code>O_SYMLINK</code></td> | |
@@ -8781,7 +8783,7 @@ The following constants are meant for use with `fs.open()`. | |||
| 8781 | 8783 | <tr> | |
| 8782 | 8784 | <td><code>O_DIRECT</code></td> | |
| 8783 | 8785 | <td>When set, an attempt will be made to minimize caching effects of file | |
| 8784 | - I/O.</td> | ||
| 8786 | + I/O. On Windows, this maps to <code>FILE_FLAG_NO_BUFFERING</code>.</td> | ||
| 8785 | 8787 | </tr> | |
| 8786 | 8788 | <tr> | |
| 8787 | 8789 | <td><code>O_NONBLOCK</code></td> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1170,10 +1170,22 @@ void DefineFsConstants(Local<Object> target) { | |||
| 1170 | 1170 | ||
| 1171 | 1171 | #ifdef O_SYNC | |
| 1172 | 1172 | NODE_DEFINE_CONSTANT(target, O_SYNC); | |
| 1173 | + #elif UV_FS_O_SYNC != 0 | ||
| 1174 | + // Windows lacks the POSIX O_SYNC macro, but libuv maps UV_FS_O_SYNC to | ||
| 1175 | + // FILE_FLAG_WRITE_THROUGH, so expose it under the portable name. | ||
| 1176 | + #define O_SYNC UV_FS_O_SYNC | ||
| 1177 | + NODE_DEFINE_CONSTANT(target, O_SYNC); | ||
| 1178 | + #undef O_SYNC | ||
| 1173 | 1179 | #endif | |
| 1174 | 1180 | ||
| 1175 | 1181 | #ifdef O_DSYNC | |
| 1176 | 1182 | NODE_DEFINE_CONSTANT(target, O_DSYNC); | |
| 1183 | + #elif UV_FS_O_DSYNC != 0 | ||
| 1184 | + // Windows lacks the POSIX O_DSYNC macro, but libuv maps UV_FS_O_DSYNC to | ||
| 1185 | + // FILE_FLAG_WRITE_THROUGH, so expose it under the portable name. | ||
| 1186 | + #define O_DSYNC UV_FS_O_DSYNC | ||
| 1187 | + NODE_DEFINE_CONSTANT(target, O_DSYNC); | ||
| 1188 | + #undef O_DSYNC | ||
| 1177 | 1189 | #endif | |
| 1178 | 1190 | ||
| 1179 | 1191 | ||
@@ -1183,6 +1195,12 @@ void DefineFsConstants(Local<Object> target) { | |||
| 1183 | 1195 | ||
| 1184 | 1196 | #ifdef O_DIRECT | |
| 1185 | 1197 | NODE_DEFINE_CONSTANT(target, O_DIRECT); | |
| 1198 | + #elif UV_FS_O_DIRECT != 0 | ||
| 1199 | + // Windows lacks the POSIX O_DIRECT macro, but libuv maps UV_FS_O_DIRECT to | ||
| 1200 | + // FILE_FLAG_NO_BUFFERING, so expose it under the portable name. | ||
| 1201 | + #define O_DIRECT UV_FS_O_DIRECT | ||
| 1202 | + NODE_DEFINE_CONSTANT(target, O_DIRECT); | ||
| 1203 | + #undef O_DIRECT | ||
| 1186 | 1204 | #endif | |
| 1187 | 1205 | ||
| 1188 | 1206 | #ifdef O_NONBLOCK | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,21 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../common'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | 3 | const fs = require('fs'); | |
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | ||
| 6 | 6 | // Check if the two constants accepted by chmod() on Windows are defined. | |
| 7 | 7 | assert.notStrictEqual(fs.constants.S_IRUSR, undefined); | |
| 8 | 8 | assert.notStrictEqual(fs.constants.S_IWUSR, undefined); | |
| 9 | 9 | ||
| 10 | + // O_SYNC, O_DSYNC and O_DIRECT have no POSIX macro on Windows, but libuv | ||
| 11 | + // honors them via FILE_FLAG_WRITE_THROUGH / FILE_FLAG_NO_BUFFERING, so they | ||
| 12 | + // are exposed under their portable names with libuv's flag values. | ||
| 13 | + if (common.isWindows) { | ||
| 14 | + assert.strictEqual(fs.constants.O_SYNC, 0x08000000); | ||
| 15 | + assert.strictEqual(fs.constants.O_DSYNC, 0x04000000); | ||
| 16 | + assert.strictEqual(fs.constants.O_DIRECT, 0x02000000); | ||
| 17 | + } | ||
| 18 | + | ||
| 10 | 19 | // Check null prototype. | |
| 11 | 20 | assert.strictEqual(Object.getPrototypeOf(fs.constants), null); | |
| 12 | 21 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments