Enlightenment CVS committal Author : codewarrior Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_file Modified Files: Ecore_File.h ecore_file.c Log Message: - add method to delete dirs recursively =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_file/Ecore_File.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- Ecore_File.h 5 Oct 2005 18:38:27 -0000 1.16 +++ Ecore_File.h 23 Oct 2005 23:21:29 -0000 1.17 @@ -48,26 +48,27 @@ } Ecore_File_Event; - EAPI int ecore_file_init (void); - EAPI int ecore_file_shutdown (void); - EAPI time_t ecore_file_mod_time (const char *file); - EAPI int ecore_file_exists (const char *file); - EAPI int ecore_file_is_dir (const char *file); - EAPI int ecore_file_mkdir (const char *dir); - EAPI int ecore_file_rmdir (const char *dir); - EAPI int ecore_file_mkpath (const char *path); - EAPI int ecore_file_cp (const char *src, const char *dst); - EAPI int ecore_file_mv (const char *src, const char *dst); - EAPI char *ecore_file_realpath (const char *file); - EAPI int ecore_file_unlink (const char *file); - EAPI char *ecore_file_get_file (char *path); - EAPI char *ecore_file_get_dir (char *path); + EAPI int ecore_file_init (void); + EAPI int ecore_file_shutdown (void); + EAPI time_t ecore_file_mod_time (const char *file); + EAPI int ecore_file_exists (const char *file); + EAPI int ecore_file_is_dir (const char *file); + EAPI int ecore_file_mkdir (const char *dir); + EAPI int ecore_file_rmdir (const char *dir); + EAPI int ecore_file_recursive_rm (const char *dir); + EAPI int ecore_file_mkpath (const char *path); + EAPI int ecore_file_cp (const char *src, const char *dst); + EAPI int ecore_file_mv (const char *src, const char *dst); + EAPI char *ecore_file_realpath (const char *file); + EAPI int ecore_file_unlink (const char *file); + EAPI char *ecore_file_get_file (char *path); + EAPI char *ecore_file_get_dir (char *path); - EAPI int ecore_file_can_exec (const char *file); - EAPI char *ecore_file_readlink (const char *link); - EAPI Ecore_List *ecore_file_ls (const char *dir); - EAPI char *ecore_file_app_exe_get (const char *app); - EAPI char *ecore_file_strip_ext (const char *file); + EAPI int ecore_file_can_exec (const char *file); + EAPI char *ecore_file_readlink (const char *link); + EAPI Ecore_List *ecore_file_ls (const char *dir); + EAPI char *ecore_file_app_exe_get (const char *app); + EAPI char *ecore_file_strip_ext (const char *file); EAPI Ecore_File_Monitor *ecore_file_monitor_add(const char *path, void (*func) (void *data, =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_file/ecore_file.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -3 -r1.33 -r1.34 --- ecore_file.c 11 Oct 2005 20:11:36 -0000 1.33 +++ ecore_file.c 23 Oct 2005 23:21:29 -0000 1.34 @@ -4,6 +4,7 @@ #include "ecore_file_private.h" #include <ctype.h> + static int init = 0; /* externally accessible functions */ @@ -94,6 +95,47 @@ } int +ecore_file_recursive_rm(const char *dir) +{ + DIR *dirp; + struct dirent *dp; + Ecore_List *list; + int ret; + + ret = 0; + dirp = opendir(dir); + if (!dirp) return ret; + + while ((dp = readdir(dirp))) + { + if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) + { + char path[PATH_MAX]; + struct stat st; + + snprintf(path, PATH_MAX, "%s/%s", dir, dp->d_name); + if (stat(path, &st) == -1) { ret = 0; continue; } + + if(S_ISDIR(st.st_mode)) + { + ecore_file_recursive_rm(path); + ecore_file_rmdir(path); + } + else if(S_ISREG(st.st_mode)||S_ISLNK(st.st_mode)) + { + ecore_file_unlink(path); + } + } + } + closedir(dirp); + + if(ecore_file_rmdir(dir)) + ret = 1; + + return ret; +} + +int ecore_file_mkpath(const char *path) { char ss[PATH_MAX]; ------------------------------------------------------- This SF.Net email is sponsored by the JBoss Inc. Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs