正文
4.1 函数stat
函数stat返回与此命名文件有关的信息结构。下面的代码实现了一个工具,显示树形目录结构,需要加两个参数,一个为目录名,一个为显示目录的深度。
#include <sys/stat.h>#include <sys/types.h>#include <stdio.h>#include <dirent.h>#include <string.h>#include <stdlib.h>#include <fcntl.h>#include <pwd.h>#include <grp.h>#include <time.h>/***************************************************************/ /*struct stat {*/ /* unsigned long st_dev; */ /* Device. */ /* unsigned long st_ino;*/ /* File serial number. */ /* unsigned int st_mode; */ /* File mode. */ /* unsigned int st_nlink; */ /* Link count. */ /* unsigned int st_uid; */ /* User ID of the file's owner. */ /* unsigned int st_gid; */ /* Group ID of the file's group. */ /* unsigned long st_rdev; *//* Device number, if device. */ /* unsigned long __pad1; */ /* long st_size; *//* Size of file,