source: trip-planner-front/node_modules/tar/lib/get-write-flag.js@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 921 bytes
Line 
1// Get the appropriate flag to use for creating files
2// We use fmap on Windows platforms for files less than
3// 512kb. This is a fairly low limit, but avoids making
4// things slower in some cases. Since most of what this
5// library is used for is extracting tarballs of many
6// relatively small files in npm packages and the like,
7// it can be a big boost on Windows platforms.
8// Only supported in Node v12.9.0 and above.
9const platform = process.env.__FAKE_PLATFORM__ || process.platform
10const isWindows = platform === 'win32'
11const fs = global.__FAKE_TESTING_FS__ || require('fs')
12
13/* istanbul ignore next */
14const { O_CREAT, O_TRUNC, O_WRONLY, UV_FS_O_FILEMAP = 0 } = fs.constants
15
16const fMapEnabled = isWindows && !!UV_FS_O_FILEMAP
17const fMapLimit = 512 * 1024
18const fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY
19module.exports = !fMapEnabled ? () => 'w'
20 : size => size < fMapLimit ? fMapFlag : 'w'
Note: See TracBrowser for help on using the repository browser.