📄 rename.html
字号:
<dt>[EROFS]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The requested operation requires writing in a directory on a read-only file system. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EXDEV]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The links named by <i>new</i> and <i>old</i> are on different file systems and the implementation does not support links betweenfile systems. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl><p>The <i>rename</i>() function may fail if:</p><dl compact><dt>[EBUSY]</dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The file named by the <i>old</i> or <i>new</i> arguments is a named STREAM. <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">More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the <i>path</i> argument. <img src="../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>As a result of encountering a symbolic link in resolution of the <i>path</i> argument, the length of the substituted pathnamestring exceeded {PATH_MAX}. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[ETXTBSY]</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 to be renamed is a pure procedure (shared text) file that is being executed. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_608_06"></a>EXAMPLES</h4><blockquote><h5><a name="tag_03_608_06_01"></a>Renaming a File</h5><p>The following example shows how to rename a file named <b>/home/cnd/mod1</b> to <b>/home/cnd/mod2</b>.</p><pre><tt>#include <stdio.h><br>int status;...status = rename("/home/cnd/mod1", "/home/cnd/mod2");</tt></pre></blockquote><h4><a name="tag_03_608_07"></a>APPLICATION USAGE</h4><blockquote><p>Some implementations mark for update the <i>st_ctime</i> field of renamed files and some do not. Applications which make use ofthe <i>st_ctime</i> field may behave differently with respect to renamed files unless they are designed to allow for eitherbehavior.</p></blockquote><h4><a name="tag_03_608_08"></a>RATIONALE</h4><blockquote><p>This <i>rename</i>() function is equivalent for regular files to that defined by the ISO C standard. Its inclusion hereexpands that definition to include actions on directories and specifies behavior when the <i>new</i> parameter names a file thatalready exists. That specification requires that the action of the function be atomic.</p><p>One of the reasons for introducing this function was to have a means of renaming directories while permitting implementations toprohibit the use of <a href="../functions/link.html"><i>link</i>()</a> and <a href="../functions/unlink.html"><i>unlink</i>()</a>with directories, thus constraining links to directories to those made by <a href="../functions/mkdir.html"><i>mkdir</i>()</a>.</p><p>The specification that if <i>old</i> and <i>new</i> refer to the same file is intended to guarantee that:</p><pre><tt>rename("x", "x");</tt></pre><p>does not remove the file.</p><p>Renaming dot or dot-dot is prohibited in order to prevent cyclical file system paths.</p><p>See also the descriptions of [ENOTEMPTY] and [ENAMETOOLONG] in <a href="rmdir.html"><i>rmdir</i>()</a> and [EBUSY] in <a href="unlink.html"><i>unlink</i>()</a> . For a discussion of [EXDEV], see <a href="link.html"><i>link</i>()</a> .</p></blockquote><h4><a name="tag_03_608_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_608_10"></a>SEE ALSO</h4><blockquote><p><a href="link.html"><i>link</i>()</a> , <a href="rmdir.html"><i>rmdir</i>()</a> , <a href="symlink.html"><i>symlink</i>()</a> ,<a href="unlink.html"><i>unlink</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/stdio.h.html"><i><stdio.h></i></a></p></blockquote><h4><a name="tag_03_608_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 3. Included for alignment with the POSIX.1-1988 standard.</p></blockquote><h4><a name="tag_03_608_12"></a>Issue 5</h4><blockquote><p>The [EBUSY] error is added to the "may fail" part of the ERRORS section.</p></blockquote><h4><a name="tag_03_608_13"></a>Issue 6</h4><blockquote><p>Extensions beyond the ISO C standard are marked.</p><p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p><ul><li><p>The [EIO] mandatory error condition is added.</p></li><li><p>The [ELOOP] mandatory error condition is added.</p></li><li><p>A second [ENAMETOOLONG] is added as an optional error condition.</p></li><li><p>The [ETXTBSY] optional error condition is added.</p></li></ul><p>The following changes were made to align with the IEEE P1003.1a draft standard:</p><ul><li><p>Details are added regarding the treatment of symbolic links.</p></li><li><p>The [ELOOP] optional error condition is added.</p></li></ul><p>The DESCRIPTION is updated to avoid use of the term "must" for application requirements.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -