+ -
当前位置:首页 → 问答吧 → stat()与 fstat()有什么区别吗?大侠们指教指教

stat()与 fstat()有什么区别吗?大侠们指教指教

时间:2010-08-02

来源:互联网

stat()与 fstat()有什么区别吗?大侠们指教指教

作者: kellenforever   发布时间: 2010-08-02

有,

可以看MAN

作者: LF_532   发布时间: 2010-08-02

man说:
  1.        int stat(const char *path, struct stat *buf);
  2.        int fstat(int fd, struct stat *buf);
复制代码
  1. stat() stats the file pointed to by path and fills in buf.

  2.        fstat() is identical to stat(), except that the file to be stat-ed is specified by the file descriptor fd.
复制代码
参数一个是用路径,一个是用文件描述符

作者: daybreakcx   发布时间: 2010-08-02

fstat前面的f代表第一个参数是用文件描述符。
类似的函数还有
chmod和fchmod

作者: edsionte   发布时间: 2010-08-02

fstat使用fd(文件描述符)作为第一个参数
stat则使用文件路径,所以stat还要进行一次path_walk()函数,确定路径是否合法

作者: hjwsm1989   发布时间: 2010-08-02

相关阅读 更多