正文
4.1 函數(shù)stat
函數(shù)stat返回與此命名文件有關的信息結構。下面的代碼實現(xiàn)了一個工具,顯示樹形目錄結構,需要加兩個參數(shù),一個為目錄名,一個為顯示目錄的深度。
#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,