#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>char *getcwd(char *buf, size_t size);//获取当前目录的绝对路径
DIR *opendir(constchar *name); //获取一个路径的目录流DIR
DIR *fdopendir(int fd); //功能同上,只是路径换成文件描述符struct dirent *readdir(DIR *dirp); //读取目录流中的一个目录struct dirent
{
ino_t d_ino; /* inode number */char d_name[256]; /* filename */
};
char* dirname(char* pathname); //获取路径的父目录char* basename(char* pathname); //获取文件名int stat(constchar *path, struct stat *buf);//将当前文件的信息放入stat结构体中struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* protection */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device ID (if special file) */
off_t st_size; /* total size, in bytes */
blksize_t st_blksize; /* blocksize for file system I/O */
blkcnt_t st_blocks; /* number of 512B blocks allocated */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last modification */
time_t st_ctime; /* time of last status change */
};