简体   繁体   English

为什么在 node.js fs 模块中删除文件被命名为“取消链接”?

[英]why in node.js fs module removing files is named “unlink”?

In node.js fs module remove files is unlink or unlinkSync.在 node.js fs 模块中删除文件是 unlink 或 unlinkSync。 Why it is named unlink?为什么它被命名为unlink? Does it have some origin from somewhere?它有什么来源吗?

unlink is a very common convention for this action. unlink是此操作的一个非常常见的约定。 See the linux manual , the GNU C Library , and PHP for examples.有关示例,请参见linux 手册GNU C 库PHP

From a discussion on Reddit on this subject:来自Reddit 关于这个主题的讨论

Deletion is a kind of unlinking.删除是一种取消链接。 It just removes the pointer/link to the file from the system tables.它只是从系统表中删除指向文件的指针/链接。 It doesn't physically go and clean the bits.它实际上并没有 go 并清理这些位。

You can have multiple links to the same file.您可以有多个指向同一个文件的链接。 The file is only deleted when the ref count reaches zero.该文件仅在引用计数达到零时被删除。 So technically its unlinking.所以从技术上讲,它是取消链接的。

Files paths are represented with links and files are accessed with their links.文件路径用链接表示,文件用它们的链接访问。 So when you remove a file you no longer have a link to access.因此,当您删除文件时,您不再有访问链接。 You unlink it.你取消链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM