Chinaunix首页 | 论坛 | 博客
  • 博客访问: 426423
  • 博文数量: 126
  • 博客积分: 35
  • 博客等级: 民兵
  • 技术积分: 1262
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-19 16:39
文章分类

全部博文(126)

文章存档

2017年(2)

2016年(20)

2015年(64)

2014年(24)

2013年(16)

我的朋友

分类: C/C++

2014-12-25 10:29:18




  1. #include
  2. struct dirent
  3. {
  4.     long d_ino;               /* inode number 索引节点号 */
  5.     off_t d_off;              /* offset to this dirent 在目录文件中的偏移 */
  6.     unsigned short d_reclen;  /* length of this d_name 文件名长 */
  7.     unsigned char d_type;     /* the type of d_name 文件类型 */
  8.     char d_name [NAME_MAX+1]; /* file name (null-terminated) 文件名,最长256字符 */
  9. }

struct __dirstream
{
    void *__fd;
    char *__data;
    int __entry_data;
    char *__ptr;
    int __entry_ptr;
    size_t __allocation;
    size_t __size;
    __libc_lock_define (, __lock)
};
typedef struct __dirstream DIR;

/*相关函数*/
 opendir(),readdir(),closedir();

struct dirent *readdir(DIR *dp);
void rewinddir(DIR *dp);
int closedir(DIR *dp);
long telldir(DIR *dp);
void seekdir(DIR *dp,long loc);




struct stat 
{
        mode_t     st_mode;       //文件访问权限
        ino_t      st_ino;       //索引节点号
        dev_t      st_dev;        //文件使用的设备号
        dev_t      st_rdev;       //设备文件的设备号
        nlink_t    st_nlink;      //文件的硬连接数
        uid_t      st_uid;        //所有者用户识别号
        gid_t      st_gid;        //组识别号
        off_t      st_size;       //以字节为单位的文件容量
        time_t     st_atime;      //最后一次访问该文件的时间
        time_t     st_mtime;      //最后一次修改该文件的时间
        time_t     st_ctime;      //最后一次改变该文件状态的时间
        blksize_t st_blksize;    //包含该文件的磁盘块的大小
        blkcnt_t   st_blocks;     //该文件所占的磁盘块
};

int stat(const char *file_name, struct stat *buf);


参考:

Linux下DIR,dirent,stat等结构体详解



阅读(783) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~