Struct dirent/Dir

Source: Internet
Author: User

tag: Io OS uses the AR file SP Div on CTI

# Include <dirent. h> struct dirent {long d_ino; // inode number index node number off_t d_off; // offset to this dirent offset unsigned short d_reclen in the directory file; // length of this d_name File Name Length unsigned char d_type; // The type of the d_name file type char d_name [name_max + 1]; // file name, the maximum value is 256 bytes.} is generally returned using the strcut dirent * dp = readdir (DIR) function. From the above, we can see that dirent has less content, so dirent also plays an index. To obtain the file information with the LS-l effect, you must rely on the stat function. 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; function dir * opendir (const char * pathname), open the file directory, and return the Dir struct pointer. Specific functions: strcut dirent * readdir (dir * DP); void rewinddir (dir * DP); int closedir (dir * DP); long telldir (dir * DP ); void seekdir (dir * DP, long LOC); the file name read through the readdir function is stored in the d_name of the dirent struct, And the int Stat (const char * file_name, struct stat * BUF); function is to obtain detailed information about the file named d_name strcut stat {mode_t st_mode; // file access permission ino_t st_ino; // index node number dev_t st_dev; // The device number dev_t st_rdev used in the file; // The device number nlink_t st_nlink of the device file; // The number of hard connections in the file uid_t st_uid; // The owner's user identification number gid_t st_gid; // group identification number off_t st_size; // The file capacity in bytes time_t st_atime; // the last file access time time_t st_mtime; // time_t st_ctime when the file was last modified; // The last time the File status was changed: blksize_t st_blksize; // the size of the disk block containing the file: blkcnt_t st_blocks; // disk block occupied by the file}

struct dirent/DIR

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.