I. Access to the directory
Function Description: Open a directory
Prototype: dir* Opendir (char *pathname);
return value:
Open success, return a directory pointer
Open failed, return null
Feature Description: Access the details of the next connection in the specified directory
Prototype: struct dirent* readdir (DIR *dirptr);
return value:
Returns a pointer to the dirent structure that contains the details of the next connection in the specified directory;
Returns NULL when no more connections
Feature Description: Closes a directory that is already open
Prototype: int Closedir (DIR *dirptr);
Return value: Call successfully returns 0, failure returns-1
Second, the directory information structure body
struct dirent
{
ino_t d_ino; /* inode number */
off_t d_off; /* offset to the next dirent */
unsigned short d_reclen; /* length of this record */
unsigned char d_type; /* type of file; not supported
by all file system types */
char d_name[256]; /* filename */
};