File tree 3 files changed +37
-0
lines changed
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()`.
5031
5031
<td><code>O_NONBLOCK</code></td>
5032
5032
<td>Flag indicating to open the file in nonblocking mode when possible.</td>
5033
5033
</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 >
5034
5040
</table >
5035
5041
5036
5042
### File Type Constants
Original file line number Diff line number Diff line change @@ -1127,6 +1127,8 @@ void DefineSystemConstants(Local<Object> target) {
1127
1127
NODE_DEFINE_CONSTANT (target, O_EXCL);
1128
1128
#endif
1129
1129
1130
+ NODE_DEFINE_CONSTANT (target, UV_FS_O_FILEMAP);
1131
+
1130
1132
#ifdef O_NOCTTY
1131
1133
NODE_DEFINE_CONSTANT (target, O_NOCTTY);
1132
1134
#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