rename
Function Prototype
int rename(const char *oldname, const char *newname);Function
If oldname is a file:
- If
newnameexists and not dir, then removenewnameand renameoldnametonewname - If
newnameexists and is dir, poses an error - must have write and execute permission for directories containing
oldnameandnewname
If oldname is a directory:
- If
newnameexists and is an empty directory, then removenewnameand renameoldnametonewname - If
newnameexists and is a file, then poses error - If
oldnameis prefix ofnewname, poses an error, e.g.,oldname = "/usr/old_dir"newname = "/usr/old_dir/new_dir"
- must have write and execute permission for directories containing
oldnameandnewname