constants.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.FLAGS = exports.ERRSTR = exports.constants = exports.SEP = void 0;
  4. exports.SEP = '/';
  5. exports.constants = {
  6. O_RDONLY: 0,
  7. O_WRONLY: 1,
  8. O_RDWR: 2,
  9. S_IFMT: 61440,
  10. S_IFREG: 32768,
  11. S_IFDIR: 16384,
  12. S_IFCHR: 8192,
  13. S_IFBLK: 24576,
  14. S_IFIFO: 4096,
  15. S_IFLNK: 40960,
  16. S_IFSOCK: 49152,
  17. O_CREAT: 64,
  18. O_EXCL: 128,
  19. O_NOCTTY: 256,
  20. O_TRUNC: 512,
  21. O_APPEND: 1024,
  22. O_DIRECTORY: 65536,
  23. O_NOATIME: 262144,
  24. O_NOFOLLOW: 131072,
  25. O_SYNC: 1052672,
  26. O_SYMLINK: 2097152,
  27. O_DIRECT: 16384,
  28. O_NONBLOCK: 2048,
  29. S_IRWXU: 448,
  30. S_IRUSR: 256,
  31. S_IWUSR: 128,
  32. S_IXUSR: 64,
  33. S_IRWXG: 56,
  34. S_IRGRP: 32,
  35. S_IWGRP: 16,
  36. S_IXGRP: 8,
  37. S_IRWXO: 7,
  38. S_IROTH: 4,
  39. S_IWOTH: 2,
  40. S_IXOTH: 1,
  41. F_OK: 0,
  42. R_OK: 4,
  43. W_OK: 2,
  44. X_OK: 1,
  45. UV_FS_SYMLINK_DIR: 1,
  46. UV_FS_SYMLINK_JUNCTION: 2,
  47. UV_FS_COPYFILE_EXCL: 1,
  48. UV_FS_COPYFILE_FICLONE: 2,
  49. UV_FS_COPYFILE_FICLONE_FORCE: 4,
  50. COPYFILE_EXCL: 1,
  51. COPYFILE_FICLONE: 2,
  52. COPYFILE_FICLONE_FORCE: 4,
  53. };
  54. exports.ERRSTR = {
  55. PATH_STR: 'path must be a string, Buffer, or Uint8Array',
  56. // FD: 'file descriptor must be a unsigned 32-bit integer',
  57. FD: 'fd must be a file descriptor',
  58. MODE_INT: 'mode must be an int',
  59. CB: 'callback must be a function',
  60. UID: 'uid must be an unsigned int',
  61. GID: 'gid must be an unsigned int',
  62. LEN: 'len must be an integer',
  63. ATIME: 'atime must be an integer',
  64. MTIME: 'mtime must be an integer',
  65. PREFIX: 'filename prefix is required',
  66. BUFFER: 'buffer must be an instance of Buffer or StaticBuffer',
  67. OFFSET: 'offset must be an integer',
  68. LENGTH: 'length must be an integer',
  69. POSITION: 'position must be an integer',
  70. };
  71. const { O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_TRUNC, O_APPEND, O_SYNC } = exports.constants;
  72. // List of file `flags` as defined by Node.
  73. var FLAGS;
  74. (function (FLAGS) {
  75. // Open file for reading. An exception occurs if the file does not exist.
  76. FLAGS[FLAGS["r"] = O_RDONLY] = "r";
  77. // Open file for reading and writing. An exception occurs if the file does not exist.
  78. FLAGS[FLAGS["r+"] = O_RDWR] = "r+";
  79. // Open file for reading in synchronous mode. Instructs the operating system to bypass the local file system cache.
  80. FLAGS[FLAGS["rs"] = O_RDONLY | O_SYNC] = "rs";
  81. FLAGS[FLAGS["sr"] = FLAGS.rs] = "sr";
  82. // Open file for reading and writing, telling the OS to open it synchronously. See notes for 'rs' about using this with caution.
  83. FLAGS[FLAGS["rs+"] = O_RDWR | O_SYNC] = "rs+";
  84. FLAGS[FLAGS["sr+"] = FLAGS['rs+']] = "sr+";
  85. // Open file for writing. The file is created (if it does not exist) or truncated (if it exists).
  86. FLAGS[FLAGS["w"] = O_WRONLY | O_CREAT | O_TRUNC] = "w";
  87. // Like 'w' but fails if path exists.
  88. FLAGS[FLAGS["wx"] = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL] = "wx";
  89. FLAGS[FLAGS["xw"] = FLAGS.wx] = "xw";
  90. // Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).
  91. FLAGS[FLAGS["w+"] = O_RDWR | O_CREAT | O_TRUNC] = "w+";
  92. // Like 'w+' but fails if path exists.
  93. FLAGS[FLAGS["wx+"] = O_RDWR | O_CREAT | O_TRUNC | O_EXCL] = "wx+";
  94. FLAGS[FLAGS["xw+"] = FLAGS['wx+']] = "xw+";
  95. // Open file for appending. The file is created if it does not exist.
  96. FLAGS[FLAGS["a"] = O_WRONLY | O_APPEND | O_CREAT] = "a";
  97. // Like 'a' but fails if path exists.
  98. FLAGS[FLAGS["ax"] = O_WRONLY | O_APPEND | O_CREAT | O_EXCL] = "ax";
  99. FLAGS[FLAGS["xa"] = FLAGS.ax] = "xa";
  100. // Open file for reading and appending. The file is created if it does not exist.
  101. FLAGS[FLAGS["a+"] = O_RDWR | O_APPEND | O_CREAT] = "a+";
  102. // Like 'a+' but fails if path exists.
  103. FLAGS[FLAGS["ax+"] = O_RDWR | O_APPEND | O_CREAT | O_EXCL] = "ax+";
  104. FLAGS[FLAGS["xa+"] = FLAGS['ax+']] = "xa+";
  105. })(FLAGS || (exports.FLAGS = FLAGS = {}));
  106. //# sourceMappingURL=constants.js.map