src: expose Windows-only fs open flags

Signed-off-by: Kirill Saied <sayed.kirill@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64775
Reviewed-By: Aviv Keller <me@aviv.sh>
This commit is contained in:
Kirill Saied authored and Antoine du Hamel committed 2026-08-26 00:55:36 +02:00
1 parent 8657497521
commit ad35fe97f0
3 files changed
+37 -2

No files matched your search

+27 -1
View File
@@ -8766,10 +8766,36 @@ The following constants are meant for use with `fs.open()`.
is available on Windows operating systems only. On other operating systems,
this flag is ignored.</td>
</tr>
<tr>
<td><code>UV_FS_O_TEMPORARY</code></td>
<td>When set, the file is deleted automatically when the last handle to it
is closed. This flag is available on Windows operating systems only. On
other operating systems, this flag is ignored.</td>
</tr>
<tr>
<td><code>UV_FS_O_SHORT_LIVED</code></td>
<td>Hint that the file is short-lived, so the system avoids flushing it to
disk when possible. This flag is available on Windows operating systems
only. On other operating systems, this flag is ignored.</td>
</tr>
<tr>
<td><code>UV_FS_O_SEQUENTIAL</code></td>
<td>Hint that the file is accessed sequentially from beginning to end, to
optimize caching. This flag is available on Windows operating systems only.
On other operating systems, this flag is ignored.</td>
</tr>
<tr>
<td><code>UV_FS_O_RANDOM</code></td>
<td>Hint that the file is accessed randomly, to optimize caching. This flag
is available on Windows operating systems only. On other operating systems,
this flag is ignored.</td>
</tr>
</table>
On Windows, only `O_APPEND`, `O_CREAT`, `O_EXCL`, `O_RDONLY`, `O_RDWR`,
`O_TRUNC`, `O_WRONLY`, and `UV_FS_O_FILEMAP` are available.
`O_TRUNC`, `O_WRONLY`, `UV_FS_O_FILEMAP`, `UV_FS_O_TEMPORARY`,
`UV_FS_O_SHORT_LIVED`, `UV_FS_O_SEQUENTIAL`, and `UV_FS_O_RANDOM` are
available.
##### File type constants
+6 -1
View File
@@ -1137,7 +1137,12 @@ void DefineFsConstants(Local<Object> target) {
NODE_DEFINE_CONSTANT(target, O_EXCL);
#endif
NODE_DEFINE_CONSTANT(target, UV_FS_O_FILEMAP);
// Windows-only open flags honored by libuv. They are 0 on other platforms.
NODE_DEFINE_CONSTANT(target, UV_FS_O_FILEMAP);
NODE_DEFINE_CONSTANT(target, UV_FS_O_TEMPORARY);
NODE_DEFINE_CONSTANT(target, UV_FS_O_SHORT_LIVED);
NODE_DEFINE_CONSTANT(target, UV_FS_O_SEQUENTIAL);
NODE_DEFINE_CONSTANT(target, UV_FS_O_RANDOM);
#ifdef O_NOCTTY
NODE_DEFINE_CONSTANT(target, O_NOCTTY);
+4
View File
@@ -35,6 +35,10 @@ const knownFsConstantNames = [
'O_CREAT',
'O_EXCL',
'UV_FS_O_FILEMAP',
'UV_FS_O_TEMPORARY',
'UV_FS_O_SHORT_LIVED',
'UV_FS_O_SEQUENTIAL',
'UV_FS_O_RANDOM',
'O_NOCTTY',
'O_TRUNC',
'O_APPEND',