Code

remove_subtree(): Use strerror() when possible
authorLuiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Wed, 25 Apr 2007 14:17:56 +0000 (11:17 -0300)
committerJunio C Hamano <junkio@cox.net>
Wed, 25 Apr 2007 20:15:27 +0000 (13:15 -0700)
Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Junio C Hamano <junkio@cox.net>
entry.c

diff --git a/entry.c b/entry.c
index 84f78025ff9f24d3ef9b2412894e18f3d9fc1859..b51addbf8d0c766c1800dc5814ce50c35321143e 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -33,7 +33,7 @@ static void remove_subtree(const char *path)
        char *name;
        
        if (!dir)
-               die("cannot opendir %s", path);
+               die("cannot opendir %s (%s)", path, strerror(errno));
        strcpy(pathbuf, path);
        name = pathbuf + strlen(path);
        *name++ = '/';
@@ -45,15 +45,15 @@ static void remove_subtree(const char *path)
                        continue;
                strcpy(name, de->d_name);
                if (lstat(pathbuf, &st))
-                       die("cannot lstat %s", pathbuf);
+                       die("cannot lstat %s (%s)", pathbuf, strerror(errno));
                if (S_ISDIR(st.st_mode))
                        remove_subtree(pathbuf);
                else if (unlink(pathbuf))
-                       die("cannot unlink %s", pathbuf);
+                       die("cannot unlink %s (%s)", pathbuf, strerror(errno));
        }
        closedir(dir);
        if (rmdir(path))
-               die("cannot rmdir %s", path);
+               die("cannot rmdir %s (%s)", path, strerror(errno));
 }
 
 static int create_file(const char *path, unsigned int mode)