文件描述符是什么?

文件描述符是什么?

在nodejs的文档中看到的,百度了一下还是不明白,请大佬帮解释一下。

When file is a file descriptor, the behavior is similar to calling fs.write() directly (which is recommended). See the notes below on using a file descriptor.

来源:https://nodejs.org/api/fs.htm...

阅读 3.5k
3 个回答

简单的讲,就是一个唯一 ID,通过这个 ID,可以访问该文件,读写该文件

nodejs file descriptor

On POSIX systems, for every process, the kernel maintains a table of currently open files and resources. Each open file is assigned a simple numeric identifier called a file descriptor. At the system-level, all file system operations use these file descriptors to identify and track each specific file. Windows systems use a different but conceptually similar mechanism for tracking resources. To simplify things for users, Node.js abstracts away the specific differences between operating systems and assigns all open files a numeric file descriptor.

文件描述符(file descriptor)在形式上是一个非负整数。实际上,它是一个索引值,每一个文件描述符会与一个打开文件相对应。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题