From 887c2a119056f68a3cf201f5e85215bb49d31a83 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 30 Oct 2012 10:44:07 +0000 Subject: [PATCH] remove unnecessary stat calls in recursive_rm, patch by Maxime Villard this patch didn't come with any changelog/news updates, so I'm assuming it's trivial enough to not need them or any backporting. someone else can take care of that if this is not the case. SVN revision: 78642 --- legacy/ecore/src/lib/ecore_file/ecore_file.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file.c b/legacy/ecore/src/lib/ecore_file/ecore_file.c index c59bf8054e..6876511fc6 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file.c @@ -399,22 +399,27 @@ ecore_file_remove(const char *file) EAPI Eina_Bool ecore_file_recursive_rm(const char *dir) { - Eina_Iterator *it; - char buf[PATH_MAX]; struct stat st; - int ret; + +#ifdef _WIN32 + char buf[PATH_MAX]; if (readlink(dir, buf, sizeof(buf) - 1) > 0) return ecore_file_unlink(dir); + if (stat(dir, &st) == -1) + return EINA_FALSE; +#else + if (lstat(dir, &st) == -1) + return EINA_FALSE; +#endif - ret = stat(dir, &st); - if ((ret == 0) && (S_ISDIR(st.st_mode))) + if (S_ISDIR(st.st_mode)) { Eina_File_Direct_Info *info; + Eina_Iterator *it; + int ret; ret = 1; - if (stat(dir, &st) == -1) return EINA_FALSE; /* WOOT: WHY ARE WE CALLING STAT TWO TIMES ??? */ - it = eina_file_direct_ls(dir); EINA_ITERATOR_FOREACH(it, info) { @@ -431,7 +436,6 @@ ecore_file_recursive_rm(const char *dir) } else { - if (ret == -1) return EINA_FALSE; return ecore_file_unlink(dir); } }