fs.open(path[, flags[, mode]], callback)


异步地打开文件。有关更多详细信息,请参阅 POSIX open(2) 文档。

¥Asynchronous file open. See the POSIX open(2) documentation for more details.

mode 设置文件模式(权限和粘滞位),但前提是文件已创建。在 Windows 上,只能操作写权限;见 fs.chmod()

¥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().

回调有两个参数 (err, fd)

¥The callback gets two arguments (err, fd).

命名文件、路径、以及命名空间 所述,某些字符 (< > : " / \ | ? *) 在 Windows 下是保留的。在 NTFS 下,如果文件名包含冒号,Node.js 将打开文件系统流,如 这个 MSDN 页面 所述。

¥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.

基于 fs.open() 的函数也表现出这种行为:fs.writeFile()fs.readFile()

¥Functions based on fs.open() exhibit this behavior as well: fs.writeFile(), fs.readFile(), etc.