fs.open(path[, flags[, mode]], callback)
path<string> | <Buffer> | <URL>flags<string> | <number> 请参阅对文件系统flags的支持。 默认值:'r'。mode<string> | <integer> 默认值:0o666(可读可写)callback<Function>
异步地打开文件。
参见 open(2)。
mode 设置文件模式(权限和粘滞位),但前提是文件已创建。
在 Windows 上,只能操作写入权限;请参阅 fs.chmod()。
回调有两个参数 (err, fd)。
在 Windows 上预留了一些字符(< > : " / \ | ? *),如命名文件、路径和命名空间所记录。
在 NTFS 下,如果文件名包含冒号,则 Node.js 将打开文件系统流,如此 MSDN 页面所述。
基于 fs.open() 的函数也表现出这种行为:fs.writeFile()、fs.readFile() 等。
path<string> | <Buffer> | <URL>flags<string> | <number> See support of file systemflags. Default:'r'.mode<string> | <integer> Default:0o666(readable and writable)callback<Function>
Asynchronous file open. See open(2).
mode sets the file mode (permission and sticky bits), but only if the file was
created. On Windows, only the write permission can be manipulated; see
fs.chmod().
The callback gets two arguments (err, fd).
Some characters (< > : " / \ | ? *) are reserved under Windows as documented
by Naming Files, Paths, and Namespaces. Under NTFS, if the filename contains
a colon, Node.js will open a file system stream, as described by
this MSDN page.
Functions based on fs.open() exhibit this behavior as well:
fs.writeFile(), fs.readFile(), etc.