Assume the operations will succeed, and set ret to 0 on fail.


SVN revision: 17881
This commit is contained in:
sebastid 2005-10-24 10:05:35 +00:00 committed by sebastid
parent 7f10622a24
commit 32732357cb
1 changed files with 22 additions and 18 deletions

View File

@ -102,13 +102,13 @@ ecore_file_recursive_rm(const char *dir)
Ecore_List *list;
int ret;
if(!ecore_file_is_dir(dir))
if (!ecore_file_is_dir(dir))
return ecore_file_unlink(dir);
ret = 0;
dirp = opendir(dir);
if (!dirp) return ret;
if (!dirp) return 0;
ret = 1;
while ((dp = readdir(dirp)))
{
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
@ -117,14 +117,18 @@ ecore_file_recursive_rm(const char *dir)
struct stat st;
snprintf(path, PATH_MAX, "%s/%s", dir, dp->d_name);
if (stat(path, &st) == -1) { ret = 0; continue; }
if (stat(path, &st) == -1)
{
ret = 0;
continue;
}
if(S_ISDIR(st.st_mode))
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))
else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))
{
ecore_file_unlink(path);
}
@ -132,8 +136,8 @@ ecore_file_recursive_rm(const char *dir)
}
closedir(dirp);
if(ecore_file_rmdir(dir))
ret = 1;
if (!ecore_file_rmdir(dir))
ret = 0;
return ret;
}