Enlightenment CVS committal

Author  : davemds
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_file


Modified Files:
        Ecore_File.h ecore_file.c 


Log Message:
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

===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_file/Ecore_File.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -3 -r1.37 -r1.38
--- Ecore_File.h        26 May 2008 05:16:33 -0000      1.37
+++ Ecore_File.h        22 Jun 2008 15:10:00 -0000      1.38
@@ -88,6 +88,7 @@
    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,
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_file/ecore_file.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -3 -r1.75 -r1.76
--- ecore_file.c        26 May 2008 05:16:33 -0000      1.75
+++ ecore_file.c        22 Jun 2008 15:10:00 -0000      1.76
@@ -701,3 +701,30 @@
 
    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;
+}



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to