int main(int argc,char* argv[])
{
DIR *dp;
struct dirent * dirp;
if (argc!=2)
{
// err_quit("a single argument (the directory name) is required");
printf("a single argument is required");
return 0;
}
if ((dp=opendir(argv[1]))==NULL)
{
// err_sys("cant open %s",argv[1]);
printf("cant open %s",argv[1]);
return 0;
}
while((dirp=readdir(dp))!=NULL)
{
struct stat buf;
if (lstat(dirp->d_name, &buf) < 0)
{
printf("lstat error");
}
if (S_ISDIR(buf.st_mode))
{
printf("%s\n",dirp->d_name);
}
}