zoukankan      html  css  js  c++  java
  • dirent / opendir(), readdir()

    dirent
    Linux下c语言编程所引用
    LINUX系统下的一个头文件,在这个目录下/usr/include, 为了获取某文件夹目录内容,所使用的结构体。
    #include<dirent.h>
    struct dirent {
    	long d_ino;  /* inode number 索引节点号 */
    	off_t d_off; /* offset to this dirent 在目录文件中的偏移 */
    	unsigned short d_reclen;  /* length of this d_name 文件名长 */
    	unsigned char d_type;     /* the type of d_name 文件类型 */
    	char d_name [NAME_MAX+1]; /* file name (null-terminated) 文件名,最长255字符 */
    }
    相关函数
    opendir(),readdir(),closedir();
    Linux C中的opendir
        #include<sys/types.h>
        #include<dirent.h>
    函数原型  DIR* opendir (const char * path );
    功能 打开一个目录,在失败的时候返回一个空的指针。
    readdir
    语法: struct dirent* readdir(DIR* dir_handle);
    返回值: dirent的结构类型
    函数种类: 文件存取
    内容说明 本函数用来读取目录。返回是dirent结构体指针,dirent结构体成员如下,
    struct dirent {
    	long d_ino; /* inode number 索引节点号 */
    	off_t d_off; /* offset to this dirent 在目录文件中的偏移 */
    	unsigned short d_reclen; /* length of this d_name 文件名长 */
    	unsigned char d_type; /* the type of d_name 文件类型 */
    	char d_name [NAME_MAX+1]; /* file name (null-terminated) 文件名,最长255字符 */
    }
    readdir相当于文件操作函数read,DIR结构体相当于文件操作里面的FILE结构体。
  • 相关阅读:
    URIError: Failed to decode param '/%PUBLIC_URL%/favicon.ico'
    Shiro授权管理
    Unable to execute 'doFinal' with cipher instance
    Shiro登录认证
    Shiro权限管理框架
    如此工作
    https真的安全吗,加密登录其实不简单
    奔波中,还是否记得来时路?
    最是伤情
    奈何桥上经过的地方,看醒了多少人
  • 原文地址:https://www.cnblogs.com/robbychan/p/3786703.html
Copyright © 2011-2022 走看看