home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Apps / ArchiveUtils / nx_arc / arcdel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-20  |  2.0 KB  |  79 lines

  1. /*
  2.  * $Log:        arcdel.c,v $
  3.  * Revision 1.3  87/08/13  17:03:13  hyc
  4.  * Run thru the indent program...
  5.  *  Revision 1.2  87/07/21  07:00:45  hyc *** empty
  6.  * log message ***
  7.  * 
  8.  */
  9.  
  10. /*
  11.  * ARC - Archive utility - ARCDEL
  12.  * 
  13.  * Version 2.09, created on 02/03/86 at 22:53:27
  14.  * 
  15.  * (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  16.  * 
  17.  * By:  Thom Henderson
  18.  * 
  19.  * Description: This file contains the routines used to delete entries in an
  20.  * archive.
  21.  * 
  22.  * Language: Computer Innovations Optimizing C86
  23.  */
  24. #include <stdio.h>
  25. #include "arc.h"
  26.  
  27. INT
  28. delarc(num, arg)        /* remove files from archive */
  29.     INT             num;    /* number of arguments */
  30.     char           *arg[];    /* pointers to arguments */
  31. {
  32.     struct heads    hdr;    /* header data */
  33.     INT             del;    /* true to delete a file */
  34.     INT             did[25];/* true when argument used */
  35.     INT             n;    /* index */
  36.  
  37.     if (!num)        /* she must specify which */
  38.         arc_abort("You must tell me which files to delete!");
  39.  
  40.     for (n = 0; n < num; n++)    /* for each argument */
  41.         did[n] = 0;    /* reset usage flag */
  42.     rempath(num, arg);    /* strip off paths */
  43.  
  44.     openarc(1);        /* open archive for changes */
  45.  
  46.     while (readhdr(&hdr, arc)) {    /* while more entries in archive */
  47.         del = 0;    /* reset delete flag */
  48.         for (n = 0; n < num; n++) {    /* for each template given */
  49.             if (match(hdr.name, arg[n])) {
  50.                 del = 1;    /* turn on delete flag */
  51.                 did[n] = 1;    /* turn on usage flag */
  52.                 break;    /* stop looking */
  53.             }
  54.         }
  55.  
  56.         if (del) {    /* skip over unwanted files */
  57.             fseek(arc, hdr.size, 1);
  58.             if (note)
  59.                 printf("Deleting file: %s\n", hdr.name);
  60.         } else {    /* else copy over file data */
  61.             writehdr(&hdr, new);    /* write out header and file */
  62.             filecopy(arc, new, hdr.size);
  63.         }
  64.     }
  65.  
  66.     hdrver = 0;        /* special end of archive type */
  67.     writehdr(&hdr, new);    /* write out archive end marker */
  68.     closearc(1);        /* close archive after changes */
  69.  
  70.     if (note) {
  71.         for (n = 0; n < num; n++) {    /* report unused arguments */
  72.             if (!did[n]) {
  73.                 printf("File not found: %s\n", arg[n]);
  74.                 nerrs++;
  75.             }
  76.         }
  77.     }
  78. }
  79.