Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_file
Modified Files:
ecore_file.c
Log Message:
fix recursive rm - does what rm -rf does now
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_file/ecore_file.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -3 -r1.46 -r1.47
--- ecore_file.c 31 Aug 2006 05:12:54 -0000 1.46
+++ ecore_file.c 31 Aug 2006 08:53:38 -0000 1.47
@@ -108,47 +108,40 @@
{
DIR *dirp;
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);
- dirp = opendir(dir);
- if (!dirp) return 0;
+ if (stat(dir, &st) == -1) return 0;
- ret = 1;
- while ((dp = readdir(dirp)))
+ if (readlink(dir, buf, sizeof(buf)) > 0)
{
- 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);
- if (stat(path, &st) == -1)
- {
- ret = 0;
- continue;
- }
+ ecore_file_unlink(dir);
+ }
+ else if (S_ISDIR(st.st_mode))
+ {
+ dirp = opendir(dir);
- if ((S_ISDIR(st.st_mode) &&
- (readlink(path, buf, sizeof(buf)) <= 0)))
- {
- ecore_file_recursive_rm(path);
- ecore_file_rmdir(path);
- }
- else
+ if (dirp)
+ {
+ while ((dp = readdir(dirp)))
{
- ecore_file_unlink(path);
+ if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
+ {
+ snprintf(path, PATH_MAX, "%s/%s", dir, dp->d_name);
+ ecore_file_recursive_rm(path);
+ }
}
+ closedir(dirp);
}
+ ecore_file_rmdir(dir);
+ }
+ else
+ {
+ ecore_file_unlink(dir);
}
- closedir(dirp);
-
- if (!ecore_file_rmdir(dir))
- ret = 0;
- return ret;
+ return 1;
}
EAPI int
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs