Function rename

Top 

Declaration:

int rename(char oldname[], char newname[]);

Description

Renames a file.

rename changes the name of a file from oldname to newname

Directories in oldname and newname need not be the same, so rename can be used to move a file from one directory to another. Wildcards are not allowed.

This function will fail (EACCES), if either file is currently open in any process.

Returned Value

On success, rename returns 0. On error (if the file cannot be renamed), it returns  -1 and the global variable is set to one of the following values:

EACCES       Permission denied: filename already exists or the path is invalid

ENOENT       No such file or directory

ENOTSAM      Not same device