diff options
Diffstat (limited to 'toys')
-rw-r--r-- | toys/posix/tar.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/toys/posix/tar.c b/toys/posix/tar.c index 66547613..f31640c5 100644 --- a/toys/posix/tar.c +++ b/toys/posix/tar.c @@ -485,8 +485,10 @@ static void extract_to_disk(void) return perror_msg(":%s: can't mkdir", name); // remove old file, if exists - if (!FLAG(k) && !S_ISDIR(ala) && unlink(name) && errno!=ENOENT) - return perror_msg("can't remove: %s", name); + if (!FLAG(k) && !S_ISDIR(ala) && unlink(name)) { + if (errno==EISDIR && !rmdir(name)); + else if (errno!=ENOENT) return perror_msg("can't remove: %s", name); + } if (S_ISREG(ala)) { // hardlink? |