#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<fcntl.h>
#include<string.h>
#include<dirent.h>
int isDirectoryEmpty(char *dirname)
{
int n = 0;
struct dirent *d;
DIR *dir = opendir(dirname);
if (dir == NULL) // Not a directory or doesn't exist
return 1;
while ((d = readdir(dir)) != NULL)
{
if (++n > 2)
break;
}
closedir(dir);
if (n <= 2) // Directory Empty
return 1;//Empty
else
return 0;//No Empty
}
05-19
4481
07-28