home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / emacs-19.28-src.tgz / tar.out / fsf / emacs / unixlib / src / rename.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  461b  |  25 lines

  1. #include "amiga.h"
  2.  
  3. int rename(const char *from, const char *to)
  4. {
  5.   long err;
  6.  
  7.   chkabort();
  8.   if (Rename(from, to)) return 0;
  9.   err = IoErr();
  10.   if (err == ERROR_OBJECT_EXISTS)
  11.     {
  12.       if (DeleteFile(to) && Rename(from, to)) return 0;
  13.       err = IoErr();
  14.  
  15.       if (err == ERROR_DELETE_PROTECTED)
  16.     {
  17.       if (SetProtection(to, 0) && DeleteFile(to) && Rename(from, to))
  18.         return 0;
  19.       err = IoErr();
  20.     }
  21.     }
  22.   errno = convert_oserr(err);
  23.   return -1;
  24. }
  25.