0101f04e8c4d3ec4ebe1ecf7b72d6b49f44962dae2e0a80d3599ca65c33baf9674bbe65f8f6f4d1fb2412d691b3a6106550eace12da8130638f5f05ad6b36a 1018 B

1234567891011121314151617181920212223
  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. import fs from 'fs';
  9. const platform = process.env.__FAKE_PLATFORM__ || process.platform;
  10. const isWindows = platform === 'win32';
  11. /* c8 ignore start */
  12. const { O_CREAT, O_TRUNC, O_WRONLY } = fs.constants;
  13. const UV_FS_O_FILEMAP = Number(process.env.__FAKE_FS_O_FILENAME__) ||
  14. fs.constants.UV_FS_O_FILEMAP ||
  15. 0;
  16. /* c8 ignore stop */
  17. const fMapEnabled = isWindows && !!UV_FS_O_FILEMAP;
  18. const fMapLimit = 512 * 1024;
  19. const fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY;
  20. export const getWriteFlag = !fMapEnabled ?
  21. () => 'w'
  22. : (size) => (size < fMapLimit ? fMapFlag : 'w');
  23. //# sourceMappingURL=get-write-flag.js.map