home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / libfake / rename.c < prev    next >
C/C++ Source or Header  |  1994-09-08  |  281b  |  20 lines

  1. /*
  2.  * fake ANSI C rename() function
  3.  */
  4.  
  5. int
  6. rename(old, new)
  7. char *old;
  8. char *new;
  9. {
  10.     (void) unlink(new);
  11.     if (link(old, new) < 0)
  12.         return(1);
  13.     if (unlink(old) < 0) {
  14.         /* oops... could link but not unlink... try to recover */
  15.         (void) unlink(new);
  16.         return(1);
  17.     }
  18.     return(0);
  19. }
  20.