Don't unlink files if we are extracting to stdout.
authorMatt Kraai <kraai@debian.org>
Fri, 1 Sep 2000 02:50:48 +0000 (02:50 -0000)
committerMatt Kraai <kraai@debian.org>
Fri, 1 Sep 2000 02:50:48 +0000 (02:50 -0000)
archival/tar.c
tar.c

index cab53aa108607eae33f3a569de5ee568c44b8e1a..597e9b80dc951288a6779ec074882089329eeb5b 100644 (file)
@@ -600,9 +600,9 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
                        printf("\n");
                }
 
-               /* Remove any clutter lying in our way */
-               if (extractFlag == TRUE)        /* .. but only if we are extracting (as */
-                       unlink( header.name);   /* opposed to listing) (rob@sysgo.de)   */
+               /* Remove files if we would overwrite them */
+               if (extractFlag == TRUE && tostdOut == FALSE)
+                       unlink(header.name);
 
                /* If we got here, we can be certain we have a legitimate 
                 * header to work with.  So work with it.  */
diff --git a/tar.c b/tar.c
index cab53aa108607eae33f3a569de5ee568c44b8e1a..597e9b80dc951288a6779ec074882089329eeb5b 100644 (file)
--- a/tar.c
+++ b/tar.c
@@ -600,9 +600,9 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
                        printf("\n");
                }
 
-               /* Remove any clutter lying in our way */
-               if (extractFlag == TRUE)        /* .. but only if we are extracting (as */
-                       unlink( header.name);   /* opposed to listing) (rob@sysgo.de)   */
+               /* Remove files if we would overwrite them */
+               if (extractFlag == TRUE && tostdOut == FALSE)
+                       unlink(header.name);
 
                /* If we got here, we can be certain we have a legitimate 
                 * header to work with.  So work with it.  */