3 <<rename>>---rename a file
12 int rename(const char *<[old]>, const char *<[new]>);
14 int _rename_r(void *<[reent]>,
15 const char *<[old]>, const char *<[new]>);
19 int rename(<[old]>, <[new]>)
23 int _rename_r(<[reent]>, <[old]>, <[new]>)
29 Use <<rename>> to establish a new name (the string at <[new]>) for a
30 file now known by the string at <[old]>. After a successful
31 <<rename>>, the file is no longer accessible by the string at <[old]>.
33 If <<rename>> fails, the file named <<*<[old]>>> is unaffected. The
34 conditions for failure depend on the host operating system.
36 The alternate function <<_rename_r>> is a reentrant version. The
37 extra argument <[reent]> is a pointer to a reentrancy structure.
40 The result is either <<0>> (when successful) or <<-1>> (when the file
41 could not be renamed).
44 ANSI C requires <<rename>>, but only specifies that the result on
45 failure be nonzero. The effects of using the name of an existing file
46 as <<*<[new]>>> may vary from one implementation to another.
48 Supporting OS subroutines required: <<link>>, <<unlink>>, or <<rename>>.
52 #include <sys/unistd.h>
56 _rename_r (ptr
, old
, new)
62 return _rename (old
,new);
64 if (_link_r (ptr
, old
, new) == -1)
67 if (_unlink_r (ptr
, old
) == -1)
69 /* ??? Should we unlink new? (rhetorical question) */
83 return _rename_r (_REENT
, old
, new);