内容简介
#include <stdio.h> int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath) |
描述
The%uA0renameat() system call operates in exactly the same way as%uA0rename(2), except for the differences described in this manual page.If the pathname given in%uA0oldpath%uA0is relative, then it is interpreted relative to the directory referred to by the file descriptor%uA0olddirfd%uA0(rather than relative to the current working directory of the calling process, as is done by%uA0rename(2) for a relative pathname).
If the pathname given in%uA0oldpath%uA0is relative and%uA0olddirfd%uA0is the special value%uA0AT_FDCWD, then%uA0oldpath%uA0is interpreted relative to the current working directory of the calling process (like%uA0rename(2)).
If the pathname given in%uA0oldpath%uA0is absolute, then%uA0olddirfd%uA0is ignored.
The interpretation of%uA0newpath%uA0is as for%uA0oldpath, except that a relative pathname is interpreted relative to the directory referred to by the file descriptor%uA0newdirfd.
返回值
On success,%uA0renameat() returns 0. On error, -1 is returned and%uA0errno%uA0is set to indicate the error.错误
The same errors that occur for%uA0rename(2) can also occur for%uA0renameat(). The following additional errors can occur for%uA0renameat():标签 | 描述 |
---|---|
EBADF | olddirfd%uA0or%uA0newdirfd%uA0is not a valid file descriptor. |
ENOTDIR | |
%uA0 | oldpath%uA0is a relative path and%uA0olddirfd%uA0is a file descriptor referring to a file other than a directory or similar for%uA0newpath%uA0andnewdirfd |