as per irc add the function:

EAPI int ecore_file_dir_is_empty(const char*dir)
Should we need to upgrade the ecore version? so apps that need this function can check for the right version?
Thanks
Dave


SVN revision: 34889
This commit is contained in:
Davide Andreoli 2008-06-22 15:10:00 +00:00
parent c543df064c
commit 288b801e42
2 changed files with 28 additions and 0 deletions

View File

@ -88,6 +88,7 @@ extern "C" {
EAPI char *ecore_file_app_exe_get (const char *app);
EAPI char *ecore_file_escape_name (const char *filename);
EAPI char *ecore_file_strip_ext (const char *file);
EAPI int ecore_file_dir_is_empty (const char *dir);
EAPI Ecore_File_Monitor * ecore_file_monitor_add(const char *path,
void (*func) (void *data, Ecore_File_Monitor *em,

View File

@ -701,3 +701,30 @@ ecore_file_strip_ext(const char *path)
return file;
}
/**
* Check if the given directory is empty. The '.' and '..' files will be ignored.
* @param dir The name of the directory to check
* @return 1 if directory is empty, 0 if it has at least one file or -1 in case of errors
*/
EAPI int
ecore_file_dir_is_empty(const char *dir)
{
DIR *dirp;
struct dirent *dp;
dirp = opendir(dir);
if (!dirp) return -1;
while ((dp = readdir(dirp)))
{
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
{
closedir(dirp);
return 0;
}
}
closedir(dirp);
return 1;
}