int List(char *path,F file[],int n)//参照网上大神的代码,进行目录下的遍历,并依次创
建文件描述符
{
struct dirent* ent = NULL;
DIR *pDir;
char dir[512];
char tmpdir[512];
struct stat statbuf;
tmpdir[0]='\0';
if((pDir=opendir(path))==NULL)
{
fprintf( stderr, " 目录%s 打开失败!\n", path );
return 0;
}
while((ent=readdir(pDir))!=NULL)
{
lstat(dir, &statbuf);
if(S_ISDIR(statbuf.st_mode))//statbuf.st_mode
文件的模式 文件 or 目录
continue;
else
{
if (strcmp(ent->d_name,".")==0 || strcmp(ent->d_name,"..")==0) continue;//忽略本
目录及父目录;
printf( " 文件:%s \n", ent->d_name );//显示出当前目录下的文件名
strcat(tmpdir,path);
strcat(tmpdir,ent->d_name);获得该文件的绝对路径
n++;
if (file[n].id=open(tmpdir,O_RDWR)==-1)/
{