Syntax | #include <stdio.h> int rename(const char *old, const char *new); | |
Description |
If old and new both refer to the same existing file, If old points to the pathname of a file that is not a directory, new must not point to the pathname of a directory. If the link named by the new argument exists, it is removed, and old is renamed to new. In this case, a link named new will remain visible to other processes throughout the renaming operation and will refer either to the file referred to by new or old before the operation began. Write access permission is required for both the directory containing old and the directory containing new. If old points to the pathname of a directory, new must not point to the pathname of a file that is not a directory. If the directory named by the new argument exists, it is removed, and old is renamed to new. In this case, a link named new will exist throughout the renaming operation and will refer either to the file referred to by new or old before the operation began. Thus, if new names an existing directory, it must be an empty directory. The pathname prefix of new must not be identical to old. Write access permission is required for the directory containing old and the directory containing new. If old points to the pathname of a directory, write access permission may be required for the directory named by old, and, if it exists, the directory named by new. If the link named by new exists, and the file ́s link count becomes 0 when it is removed, and no process has the file open, the space occupied by the file will be freed, and the file will no longer be accessible. If one or more processes have the file open when the last link is removed, the link will be removed before Upon successful completion, BS2000 The When the value | |
Return val. | 0 | if successful. |
-1 | if an error occurs; BS2000 If old and new point to files from different file systems, no changes are made. | |
Errors |
| |
|
| A component of either path prefix denies search permission; or one of the directories containing old or new denies write permissions; or write permission is required and is denied for a directory pointed to by the old or new arguments. |
|
| One of the directories named by old or new is currently in use by the system or another process, and the implementation considers this an error. |
| Extension | |
|
| The directory in which the entry for the new name is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. (End) |
|
| |
The link specified by new is a non-empty directory. | ||
| Extension | |
|
| old or new points outside the allocated address space of the process. |
|
| A signal was caught during execution of the |
|
| The directory pathname new contains a path prefix that designates the directory old (see also "Notes"). |
Extension | ||
| An I/O error occurred when creating or updating a directory entry. (End) | |
| The new argument points to a directory and the old argument points to a file that is not a directory. | |
Extension | ||
| Too many symbolic links were encountered in resolving old or new. (End) | |
BS2000 | ||
| There is no existing file with the name old | |
| old points to a directory, and the link count of the parent directory of new exceeds | |
|
| |
The length of old or new exceeds | ||
| The link named by old does not name an existing file, or either old or new points to an empty string. | |
| The directory that would contain new cannot be extended. | |
| A component of either path is not a directory, or the old argument names a directory, and the new argument names a non-directory file. | |
| The requested operation requires writing in a directory on a read-only file system. | |
| The links named by new and old are on different file systems. | |
In addition, | ||
| The file descriptor oldfd or newfd was not opened with | |
| The old parameter does not specify an absolute pathname, and the oldfd parameter does not have the value | |
| The old or new parameter does not specify an absolute pathname, and the corresponding file descriptor oldfd / newfd is not connected with a directory. | |
Notes |
The program environment determines whether | |
See also |
|