Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- libc - <b>rename</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
rename
======

Syntax
------

     #include <stdio.h>
     
     int rename(const char *oldname, const char *newname);

Description
-----------

This function renames an existing file or directory OLDNAME to NEWNAME.
If NEWNAME exists, then it is first removed.  If NEWNAME is a
directory, it must be empty (or else ERRNO will be set to `ENOTEMPTY'),
and must not include OLDNAME in its path prefix (otherwise, ERRNO will
be set to `EINVAL').  If NEWNAME exists, both OLDNAME and NEWNAME must
be of the same type (both directories or both regular files) (or else
ERRNO will be set to `ENOTDIR' or `EISDIR'), and must reside on the
same logical device (otherwise, ERRNO will be set to `EXDEV').
Wildcards are not allowed in either OLDNAME or NEWNAME.  DOS won't
allow renaming a current directory even on a non-default drive (you
will get the `EBUSY' or `EINVAL' in ERRNO).  `ENAMETOOLONG' will be
returned for pathnames which are longer than the limit imposed by DOS.
If OLDNAME doesn't exist, ERRNO will be set to `ENOENT'.  For most of
the other calamities, DOS will usually set ERRNO to `EACCES'.

If anything goes wrong during the operation of `rename()', the function
tries very hard to leave the things as ther were before it was invoked,
but it might not always succeed.

Return Value
------------

Zero on success, nonzero on failure.

Example
-------

     rename("c:/mydir/some.doc", "c:/yourdir/some.sav");
     rename("c:/path1/mydir", "c:/path2");


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson