Rename or move a file.
Syntax
#include <stdio.h>
int rename (const char *oldpath, const char *newname);
Parameters
-
oldpath
The path to the file or directory that will be renamed or moved.
-
newname
The new path to the file.
Return Value
The return value is null if successful. Otherwise, the return value is negative and errno is set:
-
ENOENT
No such file or directory.
-
EXDEV
Can not rename across file systems or physical storage media.
-
ENOSYS
The system call is not supported for this file system, or not implemented.
Remarks
SocketFS, ProcFS, PipeFS, KFS and DevFS does not support rename
. All of them
except PipeFS is currently read-only from userspace.
You cannot rename or move a file across file systems. In order to do so, copy
it first then unlink
the old file.