FS 常量


以下常量由 fs.constants 导出。

并非每个常量都适用于每个操作系统。

要使用多个常量,请使用按位或 | 运算符。

示例:

import { open, constants } from 'fs';

const {
  O_RDWR,
  O_CREAT,
  O_EXCL
} = constants;

open('/path/to/my/file', O_RDWR | O_CREAT | O_EXCL, (err, fd) => {
  // ...
});

The following constants are exported by fs.constants.

Not every constant will be available on every operating system.

To use more than one constant, use the bitwise OR | operator.

Example:

import { open, constants } from 'fs';

const {
  O_RDWR,
  O_CREAT,
  O_EXCL
} = constants;

open('/path/to/my/file', O_RDWR | O_CREAT | O_EXCL, (err, fd) => {
  // ...
});