1: /*	rename.c	1.10	85/03/24	*/
   2: 
   3: #include <stdio.h>
   4: #include "cpmio.h"
   5: #include "cpmfio.h"
   6: 
   7: /*
   8:  * Rename a cp/m file
   9:  * returns: 1 = failure, 0 = success
  10:  */
  11: 
  12: rename(cmdline)
  13:     char *cmdline;
  14: 
  15: {
  16: 
  17:     C_FILE *cio;
  18:     char oldname[9], oldext[4], newname[9], newext[4];
  19:     char *secarg, *index(), *fixname();
  20: 
  21: 
  22:     if ((secarg = index(cmdline, ' ')) == NULL) {
  23:         printf("rename: too few arguments\n");
  24:         return (1);
  25:     }
  26:     *secarg++ = '\0';
  27:     if (!(namesep(cmdline, oldname, oldext)))
  28:         return (1);
  29:     if (!(namesep(secarg, newname, newext)))
  30:         return (1);
  31: 
  32:     if (searchdir(oldname, oldext) == -1) {
  33:         fprintf(stderr, "file not found: %s\n",
  34:             fixname(oldname, oldext));
  35:         return (1);
  36:     }
  37:     if ((strncmp(oldname, newname, 8) == 0) && (strncmp(oldext, newext, 3)
  38:         == 0)) {
  39:         fprintf(stderr, "%s and %s are identical\n",
  40:             fixname(oldname, oldext), fixname(newname, newext));
  41:         return (1);
  42:     }
  43:     cio = c_open(oldname, oldext, READ);
  44:     do {
  45:         strncpy(cio->c_dirp->name, newname, 8);
  46:         strncpy(cio->c_dirp->ext, newext, 3);
  47:     } while (getnext(cio) != NULL);
  48:     savedir();
  49:     c_close(cio);
  50:     /* two calls to fprintf here because fixname is brain damaged */
  51:     fprintf(stderr, "renamed %s to ", fixname(oldname, oldext));
  52:     fprintf(stderr, "%s\n", fixname(newname, newext));
  53:     return (0);
  54: }

Defined functions

rename defined in line 12; used 1 times
Last modified: 1985-03-25
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1008
Valid CSS Valid XHTML 1.0 Strict