rreennaammee() -- System Call (libc)

Rename a file
#iinncclluuddee <ssttddiioo.hh>
iinntt rreennaammee(_o_l_d; _n_e_w)
cchhaarr *_o_l_d, *_n_e_w;

The COHERENT system call rreennaammee() changes the name of a file, from the name
pointed to by _o_l_d to that pointed to by _n_e_w. Both _o_l_d and _n_e_w must point to
a valid file  name.  If _n_e_w names a file  that already exists, the old file
is replaced by the file being renamed.

rreennaammee() returns zero if it could  rename _o_l_d, and nonzero if it could not.
If rreennaammee() could not rename _o_l_d, its name remains unchanged.

_E_x_a_m_p_l_e
This example  renames the file named in the  first command-line argument to
the name given in the second argument.

#include <stdio.h>
#include <stdlib.h>

main(argc, argv)
int argc; char *argv[];
{
    if (argc != 3) {
        fprintf(stderr, "usage: rename from to\n");
        exit(EXIT_FAILURE);
    }

    if(rename(argv[1], argv[2])) {
        perror("rename failed");
        exit(EXIT_FAILURE);
    }
    exit(EXIT_SUCCESS);
}

_S_e_e _A_l_s_o
lliibbcc, lliinnkk(), ssttddiioo.hh, uunnlliinnkk()
ANSI Standard, section 7.9.4.2
POSIX Standard, section 5.5.3

_N_o_t_e_s
The ANSI  Standard states  that rreennaammee()  fails if _o_l_d  is open, or  if its
contents must  be copied in  order to rename  it.  Under COHERENT,  it also
fails if _n_e_w is already open.
