From b19918bd366101c4b32bb798c3767cf4efac839f Mon Sep 17 00:00:00 2001 From: Maxim Sobolev Date: Wed, 3 Jul 2002 12:44:31 +0000 Subject: [PATCH] When we are extracting directory with --unlink option and the directory already exists don't spew bogus "Cannot unlink" error and exit with non-zero code. Reported by: bde --- contrib/tar/src/extract.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contrib/tar/src/extract.c b/contrib/tar/src/extract.c index c47f4c3dde5f..3dd2fce5c518 100644 --- a/contrib/tar/src/extract.c +++ b/contrib/tar/src/extract.c @@ -1140,8 +1140,12 @@ extract_archive (void) else if (typeflag == GNUTYPE_DUMPDIR) skip_member (); - if (! prepare_to_extract (CURRENT_FILE_NAME)) - break; + { + struct stat st; + if (stat (CURRENT_FILE_NAME, &st) != 0 || !S_ISDIR (st.st_mode)) + if (! prepare_to_extract (CURRENT_FILE_NAME)) + break; + } mode = ((current_stat.st_mode | (we_are_root ? 0 : MODE_WXUSR))