Changeset dbbcad4 in freewrt for tools/paxmirabilis/src/ar_subs.c


Ignore:
Timestamp:
Jul 16, 2006, 6:17:53 PM (19 years ago)
Author:
Thorsten Glaser <tg@…>
Branches:
freewrt_1_0, freewrt_2_0
Children:
006f3d5
Parents:
53c89c6
Message:

sync with MirCpio: introduce "extract to stdout" option

"schön" wbx@

git-svn-id: svn://www.freewrt.org/trunk/freewrt@207 afb5a338-a214-0410-bd46-81f09a774fd1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/paxmirabilis/src/ar_subs.c

    r53c89c6 rdbbcad4  
     1/**     $MirOS: src/bin/pax/ar_subs.c,v 1.4 2006/07/16 16:14:50 tg Exp $ */
    12/*      $OpenBSD: ar_subs.c,v 1.29 2006/01/25 17:42:08 markus Exp $     */
    23/*      $NetBSD: ar_subs.c,v 1.5 1995/03/21 09:07:06 cgd Exp $  */
     
    3536 */
    3637
    37 #ifndef lint
    38 #if 0
    39 static const char sccsid[] = "@(#)ar_subs.c     8.2 (Berkeley) 4/18/94";
    40 #else
    41 static const char rcsid[] = "$OpenBSD: ar_subs.c,v 1.29 2006/01/25 17:42:08 markus Exp $";
    42 #endif
    43 #endif /* not lint */
    44 
    45 #include <sys/types.h>
     38#include <sys/param.h>
    4639#include <sys/time.h>
    4740#include <sys/stat.h>
    48 #include <sys/param.h>
    4941#include <signal.h>
    5042#include <string.h>
     
    5648#include "pax.h"
    5749#include "extern.h"
     50#include "options.h"
     51
     52__SCCSID("@(#)ar_subs.c 8.2 (Berkeley) 4/18/94");
     53__RCSID("$MirOS: src/bin/pax/ar_subs.c,v 1.4 2006/07/16 16:14:50 tg Exp $");
    5854
    5955static void wr_archive(ARCHD *, int is_app);
     
    302298                 */
    303299                if ((arcn->pat != NULL) && (arcn->pat->chdname != NULL))
    304                         if (chdir(arcn->pat->chdname) != 0)
     300                        if (!to_stdout && chdir(arcn->pat->chdname) != 0)
    305301                                syswarn(1, errno, "Cannot chdir to %s",
    306302                                    arcn->pat->chdname);
     
    315311                         * header (as determined by the format).
    316312                         */
    317                         if ((arcn->type == PAX_HLK) || (arcn->type == PAX_HRG))
    318                                 res = lnk_creat(arcn);
    319                         else
    320                                 res = node_creat(arcn);
     313                        if (!to_stdout) {
     314                                if ((arcn->type == PAX_HLK) || (arcn->type == PAX_HRG))
     315                                        res = lnk_creat(arcn);
     316                                else
     317                                        res = node_creat(arcn);
     318                        }
    321319
    322320                        (void)rd_skip(arcn->skip + arcn->pad);
     
    334332                 * over the data and purge the name from hard link table
    335333                 */
    336                 if ((fd = file_creat(arcn)) < 0) {
     334                if (to_stdout)
     335                        fd = STDOUT_FILENO;
     336                else if ((fd = file_creat(arcn)) < 0) {
    337337                        (void)rd_skip(arcn->skip + arcn->pad);
    338338                        purg_lnk(arcn);
     
    344344                 */
    345345                res = (*frmt->rd_data)(arcn, fd, &cnt);
    346                 file_close(arcn, fd);
     346                if (fd != STDOUT_FILENO)
     347                        file_close(arcn, fd);
    347348                if (vflag && vfpart) {
    348349                        (void)putc('\n', listf);
     
    356357                 */
    357358                if ((arcn->pat != NULL) && (arcn->pat->chdname != NULL))
    358                         if (fchdir(cwdfd) != 0)
     359                        if (!to_stdout && fchdir(cwdfd) != 0)
    359360                                syswarn(1, errno,
    360361                                    "Can't fchdir to starting directory");
     
    398399
    399400        /*
    400          * if this is not append, and there are no files, we do not write a 
     401         * if this is not append, and there are no files, we do not write a
    401402         * trailer
    402403         */
Note: See TracChangeset for help on using the changeset viewer.