#include <wchar.h>
|
|
int
wrename (const wchar_t *from, const wchar_t *to); |
If the final component of from is a symbolic link, the symbolic link is renamed, not the file or directory to which it points.
If a file with a symbolic link pointing to it is renamed, then a subsequent open call on the symbolic link file would automatically remove the link file, i.e consider a symbolic file link.x pointing to a file abc.x. If the file abc.x is renamed to abcd.x then, a subsequent open call on link.x file would automatically remove link.x file.
Limitation: wrename call fails if from and to are files, and are in use(i.e., if any one of these files is kept open by a process). Parent directory time stamps remain uneffected if wrename creates a new entry in the directory, this new entry has only two time stamps, modification and access time stamps, here access time stamp is equal to modification time stamp.
/****************************************************************************************
* Detailed description : This sample code demonstrates usage of wrename system call.
*
* Preconditions : Example.cfg file should be present in the current working directory.
****************************************************************************************/
#include <wchar.h>
#include <stdio.h>
int main()
{
if(wrename(L"Example.txt" , L"Example2.txt") < 0 ) {
printf("Failed to wrename Example.txt\n");
return -1;
}
printf("wrename successful \n");
return 0;
}
Output:
wrename successful
| [EINVAL] | |
| Invalid argument. | |
| [ENAMETOOLONG] | |
| A component of a pathname exceeded 255 characters. | |
| [ENOENT] | |
| The named file does not exist. | |
| [EACCES] | |
| Search permission is denied for a component of the path prefix. | |
| [EACCES] | |
| The from argument is a parent directory of to, or an attempt is made to wrename ‘.’ or ‘..’. | |
|
© 2005-2007 Nokia |