void listDir(char *path)
{
DIR *pDir ;
struct dirent *ent ;
int i=0 ;
char childpath[512];
char childfile[512];
pDir=opendir(path);
memset(childpath,0,sizeof(childpath));
while((ent=readdir(pDir))!=NULL)
{
if(ent->d_type & DT_DIR)
{
if(strcmp(ent->d_name,".")==0 || strcmp(ent->d_name,"..")==0)
continue;
sprintf(childpath,"%s/%s",path,ent->d_name);
listDir(childpath);
}
else
{
sprintf(childfile,"%s/%s",path,ent->d_name);
}
}
closedir(pDir);
}
遍历文件夹下所有子目录下的文件(linux C )
最新推荐文章于 2022-11-24 10:57:49 发布