Apart from the fact that unlink is unix-specific (as pointed out by Chris), we read in the POSIX manual:
If path does not name a directory, remove(path) is equivalent to unlink(path).
If path names a directory, remove(path) is equivalent to rmdir(path).
As for the directory-passed unlink, we read:
The path argument must not name a directory unless the process has appropriate privileges and the implementation supports using unlink() on directories. (...) Applications should use rmdir() to remove a directory.
发布评论
评论(5)
除了 unlink 是特定于 UNIX 的事实(正如 Chris 所指出的)之外,我们在 POSIX 手册中读到:
至于目录传递的
unlink
,我们读到:Apart from the fact that unlink is unix-specific (as pointed out by Chris), we read in the POSIX manual:
As for the directory-passed
unlink
, we read:remove
是可移植的,而unlink
是 Unix 特定的。 :-Premove
is portable, andunlink
is Unix-specific. :-Premove()
函数删除路径指定的文件或目录。如果path指定一个目录,
remove(path)
相当于rmdir(路径)
。否则,它相当于unlink(path)
。来自:
手动删除
。祝你好运 ;)
The
remove()
function removes the file or directory specified by path.If path specifies a directory,
remove(path)
is the equivalent ofrmdir(path)
. Otherwise, it is the equivalent ofunlink(path)
.From:
man remove
.Good Luck ;)
unlink 不是特定于 UNIX 的,我不知道为什么人们这么说。参见 io.h。尽管您可能需要执行类似
http 的 操作://msdn.microsoft.com/en-us/library/1c3tczd6%28v=VS.100%29.aspx
http://msdn.microsoft.com/en-us/library/2da4hk1d%28v=VS.100%29.aspx
unlink is not unix-specific, i don't know why people're saying that. see io.h. although you'll probably have to do something like
http://msdn.microsoft.com/en-us/library/1c3tczd6%28v=VS.100%29.aspx
http://msdn.microsoft.com/en-us/library/2da4hk1d%28v=VS.100%29.aspx
remove()
是 C++ 标准 (N4860 29.11.14.30) 的一部分。unlink()
不是。remove()
is part of the C++ standard (N4860 29.11.14.30).unlink()
is not.