home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / zoo141_c.lzh / ZOOADD.C < prev    next >
C/C++ Source or Header  |  1987-02-07  |  22KB  |  588 lines

  1. /* zooadd.c */
  2. /*
  3. Copyright (C) 1986 Rahul Dhesi -- All rights reserved
  4. */
  5. #include "options.h"
  6. /* Adds files specified in parameter-list to archive zoo_path. */
  7.  
  8. #include "zoomem.h"             /* to define MAXADD */
  9. #include "zoo.h"
  10. #include <stdio.h>
  11. #include "various.h"
  12. #include "parse.h"
  13. #include "debug.h"
  14.  
  15. #include "portable.h"
  16. /* for low-level I/O */
  17. #ifdef NOFCNTL
  18. #include <file.h>
  19. #else
  20. #include <fcntl.h>
  21. #endif
  22.  
  23. #ifdef FLAT
  24. #include <types.h>
  25. #include <stat.h>
  26. #else
  27. #include <sys/types.h>
  28. #include <sys/stat.h>
  29. #endif
  30.  
  31. #include "zoofns.h"
  32. #include "errors.i"
  33. extern int break_hit;
  34. extern int quiet;
  35.  
  36. #ifdef LINT_ARGS
  37. void opts_add (char *, int *, int *, int *, int *, int *, int *,
  38.                int *, int *, int *, int *);
  39. int ver_too_high (struct zoo_header *);
  40. get_comment (struct direntry *, FILE *, char *);
  41. void copyfields (struct direntry *, struct tiny_header *);
  42. void storefname (struct direntry *, char *, int);
  43. char *choosefname (struct direntry *);
  44. #else
  45. void opts_add();
  46. int ver_too_high ();
  47. get_comment ();
  48. void copyfields ();
  49. void storefname ();
  50. char *choosefname ();
  51. #endif
  52.  
  53. extern struct zoo_header zoo_header;
  54.  
  55. extern char file_leader[];
  56. extern unsigned int crccode;
  57.  
  58. void zooadd(zoo_path, argc, argv, option)
  59. char *zoo_path;      /* pathname of zoo archive to add to */
  60. int argc;            /* how many filespecs supplied */
  61. char **argv;         /* array of pointers to filespecs */
  62. char *option;        /* option string */
  63. {
  64. char *whichname;                          /* which name to show user */
  65. char *flist[MAXADD];                      /* list of ptrs to input fnames */
  66. int fptr;                                 /* will point to within flist */
  67. int zoo_han;                              /* handle for open archive */
  68. int this_han;                             /* handle of file to add */
  69. char zoo_fname[LFNAMESIZE];               /* basename of archive itself */
  70. char zoo_bak[LFNAMESIZE];                 /* name of archive's backup */
  71. char this_fname[LFNAMESIZE];              /* just filename of file to add */
  72. char latest_name[LFNAMESIZE];             /* latest name in archive */
  73. long last_old = 0L;                       /* last direntry in old chain */
  74. FILE *zoo_file;                           /* stream for open archive */
  75. char *this_path;                          /* pathname of file to add */
  76.  
  77. #ifdef NOENUM
  78. #define NEW_ZOO 1
  79. #define OLD_ZOO 2
  80. int zoo_status;
  81. #else
  82. enum {NEW_ZOO, OLD_ZOO} zoo_status;       /* newly created or not */
  83. #endif
  84.  
  85. long this_dir_offset;                     /* pointers to within archive */
  86. long save_position;                       /* pointer to within archive */
  87. long prev_pos;                            /* posn of prev file of same name */
  88. struct direntry direntry;                 /* directory entry */
  89. struct direntry dir2entry;                /* spare */
  90. struct tiny_header tiny_header;           /* for Z format archives */
  91. int status;                               /* error status */
  92. int success;                              /* successful addition of file? */
  93. int addcount = 0;                         /* number added */
  94. int update=0;                             /* add only files already in archive */
  95. int suppress=0;                           /* suppress compression */
  96. int new=0;                                /* add only files not in archive */
  97. int zootime = 0;                          /* just set archive time */
  98. int add_comment = 0;                      /* add comment */
  99. int pack = 0;                             /* pack after adding */
  100. int need_dir = 1;                         /* store directories too */
  101. int delcount = 0;                         /* count of deleted entries */
  102. int exit_status = 0;                      /* exit status to set */
  103.  
  104. unsigned int latest_date = 0;             /* to set time on archive itself */
  105. unsigned int latest_time = 0;             /* .. same */
  106. int move = 0;                             /* delete after adding to archive */
  107. int longest;                              /* length of longest pathname added */
  108. int firstfile = 1;                        /* first file being added? */
  109. int z_fmt = 0;                            /* look for Z format files? */
  110.  
  111. /* on entry option points to first letter */
  112.  
  113. opts_add (option, &zootime, &quiet, &suppress, &move, &new, &pack,
  114.           &update, &add_comment, &z_fmt, &need_dir);
  115.  
  116. if (exists (zoo_path)) {
  117.    zoo_han = OPEN(zoo_path, F_RDWR);
  118.    zoo_status = OLD_ZOO;
  119. } else {
  120.    if (!zootime)
  121.       zoo_han = CREATE(zoo_path, F_RDWR);
  122.    else
  123.       zoo_han = -1;     /* don't create if just setting time */
  124.    zoo_status = NEW_ZOO;
  125. }
  126.  
  127. if (zoo_han == -1)
  128.    prterror ('f', could_not_open, zoo_path);
  129.  
  130. basename(zoo_path, zoo_fname);      /* get basename of archive */
  131. rootname (zoo_path, zoo_bak);       /* name without extension */
  132. strcat (zoo_bak, BACKUP_EXT);       /* name of backup of this archive */
  133. zoo_file = fdopen (zoo_han, "r+"); /* associate a stream with the file. */
  134.                                    /* "r+" means read & write access */
  135. if (zoo_file == NULL) {
  136.    prterror ('f', could_not_open, zoo_path);
  137. }
  138.  
  139. /* 
  140. From now on, both zoo_file and zoo_han can be used (one for stream I/O and
  141. the other for low-level I/O).  But before doing any low-level I/O, or 
  142. before switching between reading and writing on the stream, a seek
  143. must be done on the stream to flush buffered data and synchronize file
  144. pointers.
  145. */
  146.  
  147. /* Now we prepare the archive for adding one or more files.  If the archive
  148. has just been created, we write the archive header */
  149.  
  150. addfname ("",0L,0,0); /* initialize table of files already in archive */
  151. if (zoo_status == NEW_ZOO) {                 /* newly-created archive */
  152.    fwr_zooh (&zoo_header, zoo_file);
  153.    /* fwrite ((char *) &zoo_header, sizeof(zoo_header), 1, zoo_file); */
  154.    fseek (zoo_file, zoo_header.zoo_start, 0); /* seek to where data begins */
  155. } else {
  156.    /* read header and rewrite with updated version numbers */
  157.    rwheader (&zoo_header, zoo_file);
  158.    /* initialize latest_name to null string */
  159.    *latest_name = '\0';
  160.  
  161.    /* Skip existing files but add them to a list.  The variable last_old 
  162.    gets the tail of the old chain of directory entries */
  163.    skip_files (zoo_file, &latest_date, &latest_time, &delcount, 
  164.                latest_name, &last_old);
  165. }
  166. /* The file pointer is now positioned correctly to add a file to archive, 
  167. unless the null directory entry is too short.  This will be fixed below. */
  168.  
  169. /* If we are just setting time, do it and run. */
  170. if (zootime) {
  171. #ifdef NIXTIME
  172.    close (zoo_han);
  173.    setutime (zoo_path, latest_date, latest_time);
  174. #else
  175.    settime (zoo_han, latest_date, latest_time);
  176.    close (zoo_han);
  177. #endif
  178.    prterror ('m', "Archive time adjusted.\n");
  179.    exit (0);
  180. }
  181.  
  182. if (argc < 1)                       /* must have at least one file to add */
  183.    prterror ('f', internal_error);
  184.  
  185. /* make list of files, excluding archive and its backup */
  186. makelist(argc, argv, flist, MAXADD-2, zoo_fname, zoo_bak, ".", &longest);
  187. /*                                    ^^         ^^       ^^ exclude */
  188.  
  189. for (fptr = 0;  (this_path = flist[fptr]) != NULL; fptr++) {
  190.    unsigned int this_date, this_time;
  191.    int INLIST; /* boolean */
  192.    int RECENT; /* boolean */
  193.    int danger; /* if update requested and disk copy is out of date */
  194.  
  195.    basename (this_path, this_fname);   /* get just filename for later */
  196.  
  197.    this_han = OPEN(this_path, F_READ);
  198.    if (this_han == -1) {
  199.       prterror ('e', could_not_open, this_path);
  200.       exit_status++;
  201.       continue;
  202.    }
  203.  
  204. #ifndef PORTABLE
  205.    /* Test to see if this is a Z format file.  We assume the file is Z format
  206.       if (a) tag is correct and (b) type is 1 and (c) embedded filename
  207.       is not longer than FNAMESIZE.  
  208.    */
  209.    if (z_fmt) {
  210.       read (this_han, (char *) &tiny_header, sizeof(tiny_header));
  211.       if (tiny_header.tinytag == TINYTAG && tiny_header.type == 1 &&
  212.                         strlen (tiny_header.fname) <= FNAMESIZE)
  213.           /* ok */ ;
  214.       else {
  215.          close (this_han);
  216.          prterror ('e', "File %s does not have Z format.\n", this_fname);
  217.          exit_status++;
  218.          continue;
  219.       }
  220.    }
  221. #endif
  222.  
  223.    /* get file time;  also fix name */
  224. #ifndef PORTABLE
  225.    if (z_fmt) {
  226.       direntry.date = tiny_header.date;
  227.       direntry.time = tiny_header.time;
  228.       strcpy (direntry.fname, tiny_header.fname);
  229.       direntry.dirlen = direntry.namlen = 0;
  230.    } else {
  231. #endif
  232.  
  233.       /* Get timstamp of file being added */
  234. #ifdef GETUTIME
  235.       getutime (this_path, &direntry.date, &direntry.time);
  236. #else
  237.       gettime (this_han, &direntry.date, &direntry.time);
  238. #endif
  239.  
  240. #ifdef FOLD
  241.       strlwr(this_fname);
  242. #endif
  243.       dosname (this_fname, direntry.fname);  /* MSDOS filename */
  244.  
  245.    /*
  246.    Store long filename into direntry.lfname iff it is different from MSDOS
  247.    filename.  Also store directory name if need_dir is true.  Moved out of 
  248.    zooadd() so zooadd() doesn't get too big for optimization.
  249.    */
  250.    storefname (&direntry, this_path, need_dir);
  251.  
  252. #ifndef PORTABLE
  253.    }
  254. #endif
  255.  
  256. #ifdef DEBUG
  257. printf ("zooadd:  direntry.lfname = [%s]  direntry.dirname = [%s]\n",
  258.                   direntry.lfname, direntry.dirname);
  259. #endif
  260.  
  261.    /* if update option, then we add file if it is already in the archive 
  262.       AND the archived file is older */
  263.  
  264.    /* The following logic was derived from a Karnaugh map so it may
  265.       be hard to understand.  Essentially, if U=update requested,
  266.       N=new files requested, I=file is already in archive, and
  267.       R=file being archived is more recent than file already in
  268.       archive, then the boolean equation is:
  269.  
  270.       add = U' (N' + I') + U (IR  + I'N)
  271.    */
  272.  
  273.    /* Get the filename to use for this addition.  */
  274.    whichname = choosefname(&direntry);
  275.  
  276.    /* get position in archive of any old file of same name */
  277.    prev_pos = inlist (whichname, &this_date, &this_time);
  278.  
  279.    INLIST = prev_pos > 0;  /* already in archive if positive value */
  280.    if (INLIST) {
  281.       int result;
  282.       result = cmpnum (direntry.date, direntry.time, this_date, this_time);
  283.       RECENT = result > 0;
  284.       danger = result < 0;
  285.    } else
  286.       danger = 0; /* And RECENT is undefined and should not be used */
  287.  
  288.    if (
  289.          !update && (!new || !INLIST) ||
  290.          update && (INLIST && RECENT || !INLIST && new)
  291.       )
  292.          ;  /* then continue and add file */
  293.    else {
  294.       if (update && danger)
  295.          prterror ('w', "Archived copy of %s is newer.\n", whichname);
  296.       close (this_han);
  297.       continue;   /* cycle back, skip this file */
  298.    }
  299.  
  300. #ifdef CHEKDIR
  301.    /* Don't add if this is a directory */
  302.    if (isadir (this_han)) {
  303.       close (this_han);
  304.       continue;
  305.    }
  306. #endif
  307.  
  308. #ifdef CHEKUDIR
  309.    /* Don't add if this is a directory */
  310.    if (isuadir (this_path)) {
  311.       close (this_han);
  312.       continue;
  313.    }
  314. #endif
  315.  
  316.    /* Create directory entry for new file (but don't add just yet) */
  317.    /* NOTE:  we already got file date and time above for update option */
  318.    direntry.zoo_tag = ZOO_TAG;
  319.    direntry.type = 2;                  /* type is now 2 */
  320.    direntry.tz = 127;                  /* timezone unknown */
  321.    direntry.struc = 0;                 /* unstructured file */
  322.    direntry.system_id = 0;             /* identify UNIX filesystem */
  323.    direntry.var_dir_len = 
  324.       (direntry.dirlen > 0 || direntry.namlen > 0 ? 2 : 0) + 
  325.       direntry.dirlen + direntry.namlen;
  326.  
  327.    /* 
  328.    Write a null direntry entry.  Thus, if an error occurs or the program
  329.    is interrupted, the end of the archive will still be meaningful.
  330.    Special check needed for first one written.
  331.    */
  332.  
  333.    direntry.next = direntry.offset = 0L;     /* trailing null entry */
  334.    this_dir_offset = ftell (zoo_file);
  335.    if (!firstfile) {
  336.       writedir (&direntry, zoo_file);
  337.    } else {
  338.       /*
  339.       Before adding the first file to the archive, we must make sure that
  340.       the previous directory chain (if any) is properly terminated with a
  341.       null entry of the right size.  If this is a new archive, we simply
  342.       write a new null entry of the right size.  If this is an existing
  343.       archive, we must check the size of the previous trailing null entry. 
  344.       If it is too small, we will back up to the most recent real directory
  345.       entry and change its .next field to point to end of file.  
  346.       */
  347.  
  348.       if (zoo_status == NEW_ZOO) {
  349.          writedir (&direntry, zoo_file);        /* write null dir entry */
  350.       } else {
  351. #define  DIRLEN(x)   ((x.type<2) ? SIZ_DIR : (SIZ_DIRL+x.var_dir_len))
  352.          struct direntry tmpentry;
  353.          long tmppos;
  354.          int oldlen, newlen;
  355.          tmppos = ftell(zoo_file);
  356.          frd_dir (&tmpentry, zoo_file);
  357.          oldlen = DIRLEN(tmpentry);             /* get length of direntry */
  358.          newlen = DIRLEN(direntry);             /* ditto */
  359.  
  360.          if (newlen > oldlen) {                 /* trouble */
  361.             fseek (zoo_file, last_old, 0);      /* back to previous entry */
  362.             frd_dir (&tmpentry, zoo_file);
  363.             fseek (zoo_file, 0L, 2);            /* get EOF position */
  364.             tmpentry.next = ftell(zoo_file);    /* point to EOF */
  365.             fseek (zoo_file, last_old, 0);      /* back to previous entry */
  366.             writedir (&tmpentry, zoo_file);     /* update it */
  367.             fseek (zoo_file, 0L, 2);            /* to EOF ... */
  368.             this_dir_offset = ftell (zoo_file);
  369.             writedir (&direntry, zoo_file);     /* ...write null dir entry */
  370.          } else
  371.             fseek (zoo_file, tmppos, 0);        /* long enough -- let it be */
  372.       } /* if (zoo_status == NEW_ZOO) ... */
  373.    } /* if (!firstfile) ... */
  374.  
  375.    /* Now `this_dir_offset' is where the next directory entry will go */
  376.  
  377.    /* first file added goes at EOF to avoid overwriting comments */
  378.    if (firstfile) {
  379.       fseek (zoo_file, 0L, 2);                     /* EOF */
  380.       direntry.offset = ftell (zoo_file) + SIZ_FLDR;
  381.    } else {
  382.       direntry.offset = this_dir_offset + SIZ_DIRL + 
  383.          direntry.var_dir_len + SIZ_FLDR;
  384.    }
  385.  
  386.    direntry.major_ver = MAJOR_EXT_VER;    /* minimum version number needed */
  387.    direntry.minor_ver = MINOR_EXT_VER;    /* .. to extract */
  388.    direntry.deleted = 0;               /* not deleted, naturally */
  389.    direntry.comment = 0L;              /* no comment (yet) */
  390.    direntry.cmt_size = 0;          /* .. so no size either */
  391.  
  392.    save_position = direntry.offset;          /* save position in case of error */
  393.  
  394.    fseek (zoo_file, direntry.offset - SIZ_FLDR, 0);
  395.    fwrite (file_leader, SIZ_FLDR, 1, zoo_file);
  396.    fseek (zoo_file, ftell (zoo_file), 0);    /* for low-level I/O */
  397.  
  398. #ifdef PORTABLE
  399.    prterror ('m', "%-*s -- ", longest, this_path);
  400. #else
  401.    if (z_fmt)
  402.       prterror ('m', "%-12s <== %-*s -- ", 
  403.          direntry.fname, longest, this_path);
  404.    else
  405.       prterror ('m', "%-*s -- ", longest, this_path);
  406.  
  407. #ifdef COMMENT
  408.    prterror ('m', z_fmt ? "%-12s <== %-12s -- " : "%-12s -- ",
  409.                       direntry.fname, this_fname);       
  410.    prterror ('m', z_fmt ? "%-12s <== %-12s -- " : "%-12s -- ",
  411.                       direntry.fname, this_fname);       
  412. #endif /* COMMENT */
  413. #endif /* PORTABLE */
  414.  
  415.    crccode = 0;
  416.    if (z_fmt) {
  417.       direntry.packing_method = tiny_header.packing_method;
  418.       lseek (this_han, (long) (sizeof(tiny_header) + tiny_header.cmt_size), 0);
  419.       status = getfile (this_han, zoo_han, tiny_header.size_now, 1);
  420.    } else if (suppress) {                    /* suppress compression */
  421.       direntry.packing_method = 0;           /* no compression */
  422.       status = getfile (this_han, zoo_han, -1L, 1);
  423.       /* status = copyfile (this_han, zoo_han); */
  424.    } else {
  425.       direntry.packing_method = 1;           /* compressed */
  426.       status = lzc(this_han, zoo_han);       /* add with compression */
  427.    }
  428.    if (status != 0) { /* if I */
  429.       ++exit_status;                         /* remember error */
  430.       if (status == 1)
  431.          prterror ('F', no_memory);
  432.       else if (status == 2)
  433.          prterror ('F', disk_full);
  434.       else if (status == 3)
  435.          prterror ('F', "Read error.\n");
  436.       else
  437.          prterror ('F', internal_error);
  438.       success = 0;
  439.    } else {
  440.       direntry.next  = ftell(zoo_file);
  441.       direntry.size_now = direntry.next - direntry.offset;
  442.  
  443.       /* find and store original size of file just compressed */
  444.       direntry.org_size = tell (this_han);  /* should be EOF already */
  445.  
  446.       /* If the compressed one is bigger, just copy */
  447.  
  448.       if (direntry.size_now >= direntry.org_size &&   /* if II */
  449.             direntry.packing_method > 0) {
  450.          lseek (zoo_han, save_position, 0);     /* ..restore file pointer */
  451.          trunc (zoo_han);                       /* ..truncate file */
  452.          direntry.packing_method = 0;           /* ..and just copy */
  453.          lseek (this_han, 0L, 0);               /* (but rewind first!) */
  454.          crccode = 0;                           /* re-start crc from 0 */
  455.          status = getfile (this_han, zoo_han, -1L, 1);
  456.          /* status = copyfile (this_han, zoo_han); */
  457.          if (status != 0) {  /* if III */
  458.             success = 0;
  459.             printf (disk_full);
  460.             exit_status++;
  461.          } else {
  462.             success = 1;
  463.             direntry.next  = ftell(zoo_file);
  464.             direntry.size_now = direntry.next - direntry.offset;
  465.          } /* end if III */
  466.       } else {
  467.          success = 1;
  468.       } /* end if II */
  469.  
  470.    } /* end if I */
  471.  
  472.    if (success) {                               /* file successfully added */
  473.       addcount++;                               /* how many added */
  474.       direntry.file_crc = crccode;
  475.  
  476.       /* remember most recent date and time */
  477.       if (cmpnum (direntry.date,direntry.time,latest_date,latest_time) > 0) {
  478.             latest_date = direntry.date;
  479.             latest_time = direntry.time;
  480.       }
  481.  
  482.       /* mark any previous version of this file in archive as deleted */
  483.       dir2entry.comment = 0L;       /* for later use assigning to direntry */
  484.       dir2entry.cmt_size = 0;
  485.  
  486.       if (!z_fmt)
  487.          prterror ('M', " (%2d%%) ", cfactor (direntry.org_size, direntry.size_now));
  488.  
  489.       if (prev_pos > 0) {
  490.          long save_pos = ftell(zoo_file); /*DEBUG*/
  491.          ++delcount;          /* remember to pack */
  492.          prterror ('M', "replaced\n");
  493.          fseek (zoo_file, prev_pos, 0);
  494.          readdir (&dir2entry, zoo_file, 1);
  495.          dir2entry.deleted = 1;        /* mark as deleted */
  496.          fseek (zoo_file, prev_pos, 0);
  497.          writedir (&dir2entry, zoo_file);
  498.          fseek (zoo_file, save_pos, 0); /*DEBUG*/
  499.       } else prterror ('M', "added\n");
  500.  
  501.       /* Preserve any old comment if we replaced the file */
  502.       direntry.comment = dir2entry.comment;
  503.       direntry.cmt_size = dir2entry.cmt_size;
  504.  
  505. #ifndef PORTABLE
  506.       /* Copy comment if any from Z format file */
  507.       if (z_fmt && tiny_header.cmt_size != 0) {
  508.          lseek (this_han, (long) sizeof(tiny_header), 0); /* get to comment */
  509. #ifdef COMMENT
  510.          fseek (zoo_file, 0L, 2);   /* append comment to end */
  511. #endif
  512.          direntry.comment = ftell (zoo_file);
  513.          direntry.cmt_size = tiny_header.cmt_size;
  514.          /* 4th param is 0 for no CRC */
  515.          getfile (this_han, zoo_han, (long) tiny_header.cmt_size, 0);
  516.          direntry.next = ftell(zoo_file);
  517.       } 
  518. #endif
  519.  
  520.       /* if user requested comments, any previous comment in a Z format
  521.          file may now be manually overwritten */
  522.       if (add_comment && !feof (stdin)) {
  523.          show_comment (&direntry, zoo_file, 1, whichname);
  524.          get_comment (&direntry, zoo_file, this_path);
  525.          direntry.next = ftell(zoo_file);    /* update .next ptr */
  526.       } /* end if */
  527.  
  528. #ifndef PORTABLE
  529.       /* if adding Z format archive, copy relevant fields from its header */
  530.       if (z_fmt) {   /* moved out to shorten code & allow optimizer to work */
  531.          copyfields (&direntry, &tiny_header);
  532.       }
  533. #endif
  534.  
  535.       debug((printf ("zooadd:  our new .next = [%lx].\n", direntry.next)))
  536.  
  537.       {
  538.          long savepos = ftell(zoo_file);    /* save position */
  539.          fseek (zoo_file, this_dir_offset, 0);
  540.          writedir (&direntry, zoo_file);
  541.          fseek (zoo_file, savepos, 0);    /* restore position */
  542.       }
  543.  
  544.    } else {                               /* file was not properly added */
  545.       lseek (zoo_han, save_position, 0);     /* ..restore file pointer */
  546.       trunc (zoo_han);                       /* ..truncate file */
  547.    } /* end if */
  548.    close (this_han);
  549. if (!success)
  550.    break;
  551. firstfile = 0;
  552. } /* end for */
  553.  
  554. save_position = ftell (zoo_file);
  555.  
  556. /* Write a null direntry entry */
  557. fseek (zoo_file, save_position, 0);
  558. writenull (zoo_han, MAXDIRSIZE);
  559. trunc (zoo_han);    /* truncate */
  560.  
  561. #ifdef NIXTIME
  562. fclose (zoo_file);
  563. setutime (zoo_path, latest_date, latest_time);
  564. #else
  565. settime (zoo_han, latest_date, latest_time);
  566. fclose (zoo_file);
  567. #endif
  568.  
  569. if (!addcount) {                    /* no files added */
  570.    prterror ('m', "No files added.\n");
  571.    if (zoo_status == NEW_ZOO)
  572.       unlink (zoo_path);
  573. } else {
  574.    if (delcount && pack) { /* pack if user asked and found deleted entries */
  575.       prterror ('M', "-----\nNow packing...\n");
  576.       zoopack (zoo_path, "PP");
  577.    }
  578.  
  579.    /* If files to move and we added some and no error so far, delete originals */
  580.    if (move && !exit_status)
  581.       if (kill_files (flist, longest) != 0)
  582.          exit_status++;
  583. }
  584.  
  585. if (exit_status)
  586.    exit (1);
  587. } /* end zoo_add */
  588.