加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

Linux C如何打开目录并获取文件描述符

发布时间:2020-05-23 14:07:43 所属栏目:Linux 来源:互联网
导读:#include stdio.h #include string.h #include errno.h #include fcntl.h int main() { int fd; if ((fd = open(/home/zhangke, O_DIRECTORY | O_R

#include 

/ home / zhangke是一个目录,它存在.我得到错误是一个目录,所以,我怎样才能使用open()来正确获取目录的fd? 最佳答案 使用O_RDONLY而不是O_RDWR作为访问模式.从open(2)错误列表:

EISDIR pathname refers to a directory and the access requested involved writing (that is,O_WRONLY or O_RDWR is set).

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读