diff options
author | Davide Andreoli <dave@gurumeditation.it> | 2008-06-22 15:10:00 +0000 |
---|---|---|
committer | Davide Andreoli <dave@gurumeditation.it> | 2008-06-22 15:10:00 +0000 |
commit | 288b801e42f33d43a6c021a4a6e344498fb41ded (patch) | |
tree | 17f65809414ea24eeee279fe51bd8635821765d1 /legacy/ecore/src/lib/ecore_file/ecore_file.c | |
parent | c543df064cd19ad557155ce45a8aed1dd5f4da44 (diff) |
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
Diffstat (limited to '')
-rw-r--r-- | legacy/ecore/src/lib/ecore_file/ecore_file.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file.c b/legacy/ecore/src/lib/ecore_file/ecore_file.c index e99ff63206..10b9d581d4 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file.c | |||
@@ -701,3 +701,30 @@ ecore_file_strip_ext(const char *path) | |||
701 | 701 | ||
702 | return file; | 702 | return file; |
703 | } | 703 | } |
704 | |||
705 | /** | ||
706 | * Check if the given directory is empty. The '.' and '..' files will be ignored. | ||
707 | * @param dir The name of the directory to check | ||
708 | * @return 1 if directory is empty, 0 if it has at least one file or -1 in case of errors | ||
709 | */ | ||
710 | EAPI int | ||
711 | ecore_file_dir_is_empty(const char *dir) | ||
712 | { | ||
713 | DIR *dirp; | ||
714 | struct dirent *dp; | ||
715 | |||
716 | dirp = opendir(dir); | ||
717 | if (!dirp) return -1; | ||
718 | |||
719 | while ((dp = readdir(dirp))) | ||
720 | { | ||
721 | if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) | ||
722 | { | ||
723 | closedir(dirp); | ||
724 | return 0; | ||
725 | } | ||
726 | } | ||
727 | |||
728 | closedir(dirp); | ||
729 | return 1; | ||
730 | } | ||