File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -5031,6 +5031,12 @@ The following constants are meant for use with `fs.open()`.
50315031 <td><code>O_NONBLOCK</code></td>
50325032 <td>Flag indicating to open the file in nonblocking mode when possible.</td>
50335033 </tr >
5034+ <tr >
5035+ <td><code>UV_FS_O_FILEMAP</code></td>
5036+ <td>When set, a memory file mapping is used to access the file. This flag
5037+ is available on Windows operating systems only. On other operating systems,
5038+ this flag is ignored.</td>
5039+ </tr >
50345040</table >
50355041
50365042### File Type Constants
Original file line number Diff line number Diff line change @@ -1127,6 +1127,8 @@ void DefineSystemConstants(Local<Object> target) {
11271127 NODE_DEFINE_CONSTANT (target, O_EXCL);
11281128#endif
11291129
1130+ NODE_DEFINE_CONSTANT (target, UV_FS_O_FILEMAP);
1131+
11301132#ifdef O_NOCTTY
11311133 NODE_DEFINE_CONSTANT (target, O_NOCTTY);
11321134#endif
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ require ( '../common' ) ;
3+ const assert = require ( 'assert' ) ;
4+ const fs = require ( 'fs' ) ;
5+ const join = require ( 'path' ) . join ;
6+
7+ const {
8+ O_CREAT = 0 ,
9+ O_RDONLY = 0 ,
10+ O_TRUNC = 0 ,
11+ O_WRONLY = 0 ,
12+ UV_FS_O_FILEMAP = 0
13+ } = fs . constants ;
14+
15+ const tmpdir = require ( '../common/tmpdir' ) ;
16+ tmpdir . refresh ( ) ;
17+
18+ // Run this test on all platforms. While UV_FS_O_FILEMAP is only available on
19+ // Windows, it should be silently ignored on other platforms.
20+
21+ const filename = join ( tmpdir . path , 'fmap.txt' ) ;
22+ const text = 'Memory File Mapping Test' ;
23+
24+ const mw = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY ;
25+ const mr = UV_FS_O_FILEMAP | O_RDONLY ;
26+
27+ fs . writeFileSync ( filename , text , { flag : mw } ) ;
28+ const r1 = fs . readFileSync ( filename , { encoding : 'utf8' , flag : mr } ) ;
29+ assert . strictEqual ( r1 , text ) ;
You can’t perform that action at this time.
0 commit comments