summaryrefslogtreecommitdiff
path: root/sysutils/radmind/files/patch-lapply.c
blob: 63113803d7d9e532d3ec87f3ec5d0c8a6d79a0f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--- ./lapply.c.orig	2010-12-12 22:42:49.000000000 -0500
+++ ./lapply.c	2012-03-20 14:37:54.000000000 -0400
@@ -651,27 +651,37 @@
 filechecklist:
 		if ( head == NULL ) {
 		    if ( unlink( path ) != 0 ) {
-			perror( path );
-			goto error2;
-		    }
-		    if ( !quiet && !showprogress ) {
-			printf( "%s: deleted\n", path );
-		    }
-		    if ( showprogress ) {
-			progressupdate( PROGRESSUNIT, path );
-		    }
-		} else {
-		    if ( ischildcase( path, head->path, case_sensitive )) {
-			if ( unlink( path ) != 0 ) {
+			if ( !force || errno != ENOENT ) {
 			    perror( path );
 			    goto error2;
 			}
+			fprintf( stderr, "Warning: failed to remove %s: %s\n",
+				path, strerror( errno ));
+		    } else {
 			if ( !quiet && !showprogress ) {
 			    printf( "%s: deleted\n", path );
 			}
 			if ( showprogress ) {
 			    progressupdate( PROGRESSUNIT, path );
 			}
+		    }
+		} else {
+		    if ( ischildcase( path, head->path, case_sensitive )) {
+			if ( unlink( path ) != 0 ) {
+			    if ( !force || errno != ENOENT ) {
+				perror( path );
+				goto error2;
+			    }
+			    fprintf( stderr, "Warning: failed to remove %s: "
+				    "%s\n", path, strerror( errno ));
+			} else {
+			    if ( !quiet && !showprogress ) {
+				printf( "%s: deleted\n", path );
+			    }
+			    if ( showprogress ) {
+				progressupdate( PROGRESSUNIT, path );
+			    }
+			}
 		    } else {
 			/* remove head */
 			if ( rmdir( head->path ) != 0 ) {