Back to index

glibc  2.9
Functions
rename.c File Reference
#include <stdio.h>
#include <unistd.h>
#include <errno.h>

Go to the source code of this file.

Functions

int rename (char *old, const char *new) const

Function Documentation

int rename ( char *  old,
const char *  new 
) const

Definition at line 25 of file rename.c.

{
  int save = errno;
  if (__link (old, new) < 0)
    {
      if (errno == EEXIST)
       {
         __set_errno (save);
         /* Race condition, required for 1003.1 conformance.  */
         if (__unlink (new) < 0 ||
             __link (old, new) < 0)
           return -1;
       }
      else
       return -1;
    }
  if (__unlink (old) < 0)
    {
      save = errno;
      if (__unlink (new) == 0)
       __set_errno (save);
      return -1;
    }
  return 0;
}

Here is the call graph for this function: