remove_subtree(): Use strerror() when possible
Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
da94faf671
commit
cc2903fc70
8
entry.c
8
entry.c
@ -33,7 +33,7 @@ static void remove_subtree(const char *path)
|
|||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
if (!dir)
|
if (!dir)
|
||||||
die("cannot opendir %s", path);
|
die("cannot opendir %s (%s)", path, strerror(errno));
|
||||||
strcpy(pathbuf, path);
|
strcpy(pathbuf, path);
|
||||||
name = pathbuf + strlen(path);
|
name = pathbuf + strlen(path);
|
||||||
*name++ = '/';
|
*name++ = '/';
|
||||||
@ -45,15 +45,15 @@ static void remove_subtree(const char *path)
|
|||||||
continue;
|
continue;
|
||||||
strcpy(name, de->d_name);
|
strcpy(name, de->d_name);
|
||||||
if (lstat(pathbuf, &st))
|
if (lstat(pathbuf, &st))
|
||||||
die("cannot lstat %s", pathbuf);
|
die("cannot lstat %s (%s)", pathbuf, strerror(errno));
|
||||||
if (S_ISDIR(st.st_mode))
|
if (S_ISDIR(st.st_mode))
|
||||||
remove_subtree(pathbuf);
|
remove_subtree(pathbuf);
|
||||||
else if (unlink(pathbuf))
|
else if (unlink(pathbuf))
|
||||||
die("cannot unlink %s", pathbuf);
|
die("cannot unlink %s (%s)", pathbuf, strerror(errno));
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
if (rmdir(path))
|
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)
|
static int create_file(const char *path, unsigned int mode)
|
||||||
|
Loading…
Reference in New Issue
Block a user