diff --git a/doc/api/fs.md b/doc/api/fs.md index 9cb84007b3b815..b731e7eaaa961e 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -8733,10 +8733,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. + + UV_FS_O_TEMPORARY + 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. + + + UV_FS_O_SHORT_LIVED + 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. + + + UV_FS_O_SEQUENTIAL + 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. + + + UV_FS_O_RANDOM + 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. + 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 diff --git a/src/node_constants.cc b/src/node_constants.cc index 8abf3fd8afe483..23579661191f45 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -1137,7 +1137,12 @@ void DefineFsConstants(Local 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); diff --git a/test/parallel/test-fs-constants.js b/test/parallel/test-fs-constants.js index cdecfe5591631a..b2ea4ce20ee64a 100644 --- a/test/parallel/test-fs-constants.js +++ b/test/parallel/test-fs-constants.js @@ -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',