delorie.com/djgpp/doc/libc/libc_662.html | search |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#include <stdio.h> int rename(const char *oldname, const char *newname); |
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.
Zero on success, nonzero on failure.
ANSI/ISO C | C89; C99 |
POSIX | 1003.2-1992; 1003.1-2001 |
rename("c:/mydir/some.doc", "c:/yourdir/some.sav"); rename("c:/path1/mydir", "c:/path2"); |
webmaster | delorie software privacy |
Copyright © 2004 | Updated Apr 2004 |