【发布时间】:2014-06-03 20:32:17
【问题描述】:
如果我有一个具有已知文件描述符的打开文件,使用fstat() 与stat() 相比有什么优势?为什么不只有一个功能?
int fstat(int fildes, struct stat *buf)
int stat(const char *path, struct stat *buf)
【问题讨论】:
-
如果进程与文件描述符相关我们可以使用fstat(),如果名称可用则可以使用stat()。
-
根据它可能使用的工作进程,例如你已经用文件描述符打开了文件,当时使用 fstat() 。但是如果文件没有打开,那么你可以使用 stat() 。那就是不同的。
标签: c file system-calls stat fstat