[pacman-dev] [patch] util.c/_alpm_rmrf patch

Nagy Gabor ngaba at petra.hos.u-szeged.hu
Wed Mar 14 13:17:10 EDT 2007


--- util.c.old	2007-03-14 17:56:40.000000000 +0100
+++ util.c	2007-03-14 18:03:00.000000000 +0100
@@ -310,21 +310,20 @@
 	struct dirent *dp;
 	DIR *dirp;
 	char name[PATH_MAX];
-  struct stat st;
+	struct stat st;
 
-	if(stat(path, &st) == 0) {
-		if(S_ISREG(st.st_mode)) {
+	if(lstat(path, &st) == 0) {
+		if(!S_ISDIR(st.st_mode)) {
 			if(!unlink(path)) {
 				return(0);
 			} else {
 				if(errno == ENOENT) {
 					return(0);
 				} else {
-					/* not a directory */
 					return(1);
 				}
 			}
-		} else if(S_ISDIR(st.st_mode)) {
+		} else {
 			if((dirp = opendir(path)) == (DIR *)-1) {
 				return(1);
 			}
------------------------------------
A note: some functions can be removed from pacman/util.c because the 
"same" function exists in alpm/util.c (such as rmrf, makepath).
Bye, Nagy Gabor




More information about the pacman-dev mailing list