1'use strict'; 2require('../common'); 3const assert = require('assert'); 4const fs = require('fs'); 5const join = require('path').join; 6 7const { 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 15const tmpdir = require('../common/tmpdir'); 16tmpdir.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 21const filename = join(tmpdir.path, 'fmap.txt'); 22const text = 'Memory File Mapping Test'; 23 24const mw = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY; 25const mr = UV_FS_O_FILEMAP | O_RDONLY; 26 27fs.writeFileSync(filename, text, { flag: mw }); 28const r1 = fs.readFileSync(filename, { encoding: 'utf8', flag: mr }); 29assert.strictEqual(r1, text); 30