linux-C实现查看目录中所有文件
买了本Advanced Programming in the UNIX Environment,感觉不错,不愧被称为圣经,最近一段时间可能要看它了,写了地一个程序,查看目录的所有文件
首先说说DIR这一结构体,以下为DIR结构体的定义:
/*1. struct dirent 2. { 3. long d_ino; //inode number 索引节点号 4. 5. off_t d_off; // offset to this dirent 在目录文件中的偏移 6. 7. unsigned short d_reclen; //length of this d_name 文件名长 8. 9. unsigned char d_type; // the type of d_name 文件类型 10. 11. char d_name [NAME_MAX+1]; //file name (null-terminated) 文件名,最长255字符 12. } */其他的细节待以后看书再补全