tar: Use remove() instead of unlink() so we can work on directories too

This commit is contained in:
sin 2015-04-23 14:05:43 +01:00
parent 3419f94d83
commit fb1595a69c

2
tar.c
View File

@ -201,7 +201,7 @@ unarchive(char *fname, ssize_t l, char b[BLKSIZ])
if (!mflag && ((mtime = strtol(h->mtime, &p, 8)) < 0 || *p != '\0')) if (!mflag && ((mtime = strtol(h->mtime, &p, 8)) < 0 || *p != '\0'))
eprintf("strtol %s: invalid number\n", h->mtime); eprintf("strtol %s: invalid number\n", h->mtime);
if (unlink(fname) < 0 && errno != ENOENT && errno != EISDIR) if (remove(fname) < 0 && errno != ENOENT)
eprintf("unlink %s:", fname); eprintf("unlink %s:", fname);
tmp = estrdup(fname); tmp = estrdup(fname);