Patryk Kaczmarek <patryk.k@samsung.com>
Daniel Willmann <d.willmann@samsung.com>
Michal Pakula vel Rutka <m.pakula@samsung.com>
-Maxime Villard <rustyBSD@gmx.fr>
EAPI Eina_Bool
ecore_file_recursive_rm(const char *dir)
{
+ Eina_Iterator *it;
+ char buf[PATH_MAX];
struct stat st;
+ int ret;
- if (lstat(dir, &st) == -1)
- return EINA_FALSE;
+ if (readlink(dir, buf, sizeof(buf) - 1) > 0)
+ return ecore_file_unlink(dir);
- if (S_ISDIR(st.st_mode))
+ ret = stat(dir, &st);
+ if ((ret == 0) && (S_ISDIR(st.st_mode)))
{
Eina_File_Direct_Info *info;
- Eina_Iterator *it;
- int ret = 1;
+
+ 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)
else
return EINA_FALSE;
}
-
- return ecore_file_unlink(dir);
+ else
+ {
+ if (ret == -1) return EINA_FALSE;
+ return ecore_file_unlink(dir);
+ }
}
static inline Eina_Bool
ecore_file_readlink(const char *lnk)
{
char buf[PATH_MAX];
- ssize_t count;
+ int count;
if ((count = readlink(lnk, buf, sizeof(buf) - 1)) < 0) return NULL;
buf[count] = 0;