forked from enlightenment/efl
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:
parent
c543df064c
commit
288b801e42
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue