⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rename.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>rename</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="rename"></a> <a name="tag_03_608"></a><!-- rename --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright &copy; 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_608_01"></a>NAME</h4><blockquote>rename - rename a file</blockquote><h4><a name="tag_03_608_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include &lt;<a href="../basedefs/stdio.h.html">stdio.h</a>&gt;<br><br> int rename(const char *</tt><i>old</i><tt>, const char *</tt><i>new</i><tt>);<br></tt></code></p></blockquote><h4><a name="tag_03_608_03"></a>DESCRIPTION</h4><blockquote><div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"border="0"> The functionality described on this reference page is aligned with the ISO&nbsp;C standard. Any conflict between therequirements described here and the ISO&nbsp;C standard is unintentional. This volume of IEEE&nbsp;Std&nbsp;1003.1-2001 defers tothe ISO&nbsp;C standard. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div><p>The <i>rename</i>() function shall change the name of a file. The <i>old</i> argument points to the pathname of the file to berenamed. The <i>new</i> argument points to the new pathname of the file.</p><p><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Ifeither the <i>old</i> or <i>new</i> argument names a symbolic link, <i>rename</i>() shall operate on the symbolic link itself, andshall not resolve the last component of the argument. If the <i>old</i> argument and the <i>new</i> argument resolve to the sameexisting file, <i>rename</i>() shall return successfully and perform no other action.</p><p>If the <i>old</i> argument points to the pathname of a file that is not a directory, the <i>new</i> argument shall not point tothe pathname of a directory. If the link named by the <i>new</i> argument exists, it shall be removed and <i>old</i> renamed to<i>new</i>. In this case, a link named <i>new</i> shall remain visible to other processes throughout the renaming operation andrefer either to the file referred to by <i>new</i> or <i>old</i> before the operation began. Write access permission is requiredfor both the directory containing <i>old</i> and the directory containing <i>new</i>.</p><p>If the <i>old</i> argument points to the pathname of a directory, the <i>new</i> argument shall not point to the pathname of afile that is not a directory. If the directory named by the <i>new</i> argument exists, it shall be removed and <i>old</i> renamedto <i>new</i>. In this case, a link named <i>new</i> shall exist throughout the renaming operation and shall refer either to thedirectory referred to by <i>new</i> or <i>old</i> before the operation began. If <i>new</i> names an existing directory, it shallbe required to be an empty directory.</p><p>If the <i>old</i> argument points to a pathname of a symbolic link, the symbolic link shall be renamed. If the <i>new</i>argument points to a pathname of a symbolic link, the symbolic link shall be removed.</p><p>The <i>new</i> pathname shall not contain a path prefix that names <i>old</i>. Write access permission is required for thedirectory containing <i>old</i> and the directory containing <i>new</i>. If the <i>old</i> argument points to the pathname of adirectory, write access permission may be required for the directory named by <i>old</i>, and, if it exists, the directory named by<i>new</i>.</p><p>If the link named by the <i>new</i> argument exists and the file's link count becomes 0 when it is removed and no process hasthe file open, the space occupied by the file shall be freed and the file shall no longer be accessible. If one or more processeshave the file open when the last link is removed, the link shall be removed before <i>rename</i>() returns, but the removal of thefile contents shall be postponed until all references to the file are closed.</p><p>Upon successful completion, <i>rename</i>() shall mark for update the <i>st_ctime</i> and <i>st_mtime</i> fields of the parentdirectory of each file.</p><p>If the <i>rename</i>() function fails for any reason other than [EIO], any file named by <i>new</i> shall be unaffected. <imgsrc="../images/opt-end.gif" alt="[Option End]" border="0"></p></blockquote><h4><a name="tag_03_608_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, <i>rename</i>() shall return 0; otherwise, -1 shall be returned, <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> <i>errno</i> shallbe set to indicate the error, <img src="../images/opt-end.gif" alt="[Option End]" border="0"> and neither the file named by<i>old</i> nor the file named by <i>new</i> shall be changed or created.</p></blockquote><h4><a name="tag_03_608_05"></a>ERRORS</h4><blockquote><p>The <i>rename</i>() function shall fail if:</p><dl compact><dt>[EACCES]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Acomponent of either path prefix denies search permission; or one of the directories containing <i>old</i> or <i>new</i> denieswrite permissions; or, write permission is required and is denied for a directory pointed to by the <i>old</i> or <i>new</i>arguments. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EBUSY]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The directory named by <i>old</i> or <i>new</i> is currently in use by the system or another process, and the implementationconsiders this an error. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EEXIST]&nbsp;or&nbsp;[ENOTEMPTY]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"><br>The link named by <i>new</i> is a directory that is not an empty directory. <img src="../images/opt-end.gif" alt="[Option End]"border="0"></dd><dt>[EINVAL]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The <i>new</i> directory pathname contains a path prefix that names the <i>old</i> directory. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EIO]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Aphysical I/O error has occurred. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EISDIR]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The <i>new</i> argument points to a directory and the <i>old</i> argument points to a file that is not a directory. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[ELOOP]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Aloop exists in symbolic links encountered during resolution of the <i>path</i> argument. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EMLINK]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The file named by <i>old</i> is a directory, and the link count of the parent directory of <i>new</i> would exceed {LINK_MAX}. <imgsrc="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[ENAMETOOLONG]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"><br>The length of the <i>old</i> or <i>new</i> argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[ENOENT]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The link named by <i>old</i> does not name an existing file, or either <i>old</i> or <i>new</i> points to an empty string. <imgsrc="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[ENOSPC]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The directory that would contain <i>new</i> cannot be extended. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[ENOTDIR]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Acomponent of either path prefix is not a directory; or the <i>old</i> argument names a directory and <i>new</i> argument names anon-directory file. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EPERM] or [EACCES]</dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"><br>The S_ISVTX flag is set on the directory containing the file referred to by <i>old</i> and the caller is not the file owner, nor isthe caller the directory owner, nor does the caller have appropriate privileges; or <i>new</i> refers to an existing file, theS_ISVTX flag is set on the directory containing this file, and the caller is not the file owner, nor is the caller the directoryowner, nor does the caller have appropriate privileges. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -