forked from enlightenment/efl
fix recursive rm - does what rm -rf does now
SVN revision: 25239
This commit is contained in:
parent
ae60acfeb4
commit
a274d114ee
|
@ -108,47 +108,40 @@ ecore_file_recursive_rm(const char *dir)
|
||||||
{
|
{
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
int ret;
|
char path[PATH_MAX], buf[PATH_MAX];;
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
if (!ecore_file_is_dir(dir))
|
|
||||||
return ecore_file_unlink(dir);
|
|
||||||
|
|
||||||
|
if (stat(dir, &st) == -1) return 0;
|
||||||
|
|
||||||
|
if (readlink(dir, buf, sizeof(buf)) > 0)
|
||||||
|
{
|
||||||
|
ecore_file_unlink(dir);
|
||||||
|
}
|
||||||
|
else if (S_ISDIR(st.st_mode))
|
||||||
|
{
|
||||||
dirp = opendir(dir);
|
dirp = opendir(dir);
|
||||||
if (!dirp) return 0;
|
|
||||||
|
|
||||||
ret = 1;
|
if (dirp)
|
||||||
|
{
|
||||||
while ((dp = readdir(dirp)))
|
while ((dp = readdir(dirp)))
|
||||||
{
|
{
|
||||||
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
|
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
|
||||||
{
|
{
|
||||||
char path[PATH_MAX], buf[PATH_MAX];;
|
|
||||||
struct stat st;
|
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "%s/%s", dir, dp->d_name);
|
snprintf(path, PATH_MAX, "%s/%s", dir, dp->d_name);
|
||||||
if (stat(path, &st) == -1)
|
|
||||||
{
|
|
||||||
ret = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((S_ISDIR(st.st_mode) &&
|
|
||||||
(readlink(path, buf, sizeof(buf)) <= 0)))
|
|
||||||
{
|
|
||||||
ecore_file_recursive_rm(path);
|
ecore_file_recursive_rm(path);
|
||||||
ecore_file_rmdir(path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ecore_file_unlink(path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
|
}
|
||||||
|
ecore_file_rmdir(dir);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ecore_file_unlink(dir);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ecore_file_rmdir(dir))
|
return 1;
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
|
|
Loading…
Reference in New Issue