11cb0ef41Sopenharmony_ci// Get the appropriate flag to use for creating files 21cb0ef41Sopenharmony_ci// We use fmap on Windows platforms for files less than 31cb0ef41Sopenharmony_ci// 512kb. This is a fairly low limit, but avoids making 41cb0ef41Sopenharmony_ci// things slower in some cases. Since most of what this 51cb0ef41Sopenharmony_ci// library is used for is extracting tarballs of many 61cb0ef41Sopenharmony_ci// relatively small files in npm packages and the like, 71cb0ef41Sopenharmony_ci// it can be a big boost on Windows platforms. 81cb0ef41Sopenharmony_ci// Only supported in Node v12.9.0 and above. 91cb0ef41Sopenharmony_ciconst platform = process.env.__FAKE_PLATFORM__ || process.platform 101cb0ef41Sopenharmony_ciconst isWindows = platform === 'win32' 111cb0ef41Sopenharmony_ciconst fs = global.__FAKE_TESTING_FS__ || require('fs') 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci/* istanbul ignore next */ 141cb0ef41Sopenharmony_ciconst { O_CREAT, O_TRUNC, O_WRONLY, UV_FS_O_FILEMAP = 0 } = fs.constants 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst fMapEnabled = isWindows && !!UV_FS_O_FILEMAP 171cb0ef41Sopenharmony_ciconst fMapLimit = 512 * 1024 181cb0ef41Sopenharmony_ciconst fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY 191cb0ef41Sopenharmony_cimodule.exports = !fMapEnabled ? () => 'w' 201cb0ef41Sopenharmony_ci : size => size < fMapLimit ? fMapFlag : 'w' 21